Skip to content

Commit

Permalink
fix: don't encode url for copy, support route param with regex (#1017)
Browse files Browse the repository at this point in the history
* fix: don't encode url for copy

* fix: always rendering

* fix: support route with regex
  • Loading branch information
hyoban committed Jun 13, 2024
1 parent 096589d commit 97d7470
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/lib/rsshub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ function ruleHandler(rule: Rule, params, url, html, success, fail) {
resultWithParams = rule.target
}

// clean params with regex requirements
// /npm/package/:name{(@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*} -> /npm/package/:name
resultWithParams = resultWithParams.replace(
/\/:\w+\{[^}]*\}(?=\/|$)/g,
(match) => match.replace(/\{[^}]*\}/, ""),
)

if (resultWithParams) {
// if no :param in resultWithParams, requiredParams will be null
// in that case, just skip the following steps and return resultWithParams
Expand Down
5 changes: 3 additions & 2 deletions src/popup/RSSItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ function RSSItem({
hidePreview?: boolean
}) {
const [config, setConfig] = useState(defaultConfig)
getConfig().then(setConfig)
useEffect(() => {
getConfig().then(setConfig)
}, [])
const [_, copy] = useCopyToClipboard()
const [copied, setCopied] = useState(false)
useEffect(() => {
Expand All @@ -43,7 +45,6 @@ function RSSItem({
chrome.i18n.getMessage("current"),
)
}
url = encodeURI(url)
const encodedUrl = encodeURIComponent(url)

return (
Expand Down

0 comments on commit 97d7470

Please sign in to comment.