diff --git a/src/lib/rsshub.ts b/src/lib/rsshub.ts index 723dc44..53145bc 100644 --- a/src/lib/rsshub.ts +++ b/src/lib/rsshub.ts @@ -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 diff --git a/src/popup/RSSItem.tsx b/src/popup/RSSItem.tsx index 4ddb00f..423a602 100644 --- a/src/popup/RSSItem.tsx +++ b/src/popup/RSSItem.tsx @@ -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(() => { @@ -43,7 +45,6 @@ function RSSItem({ chrome.i18n.getMessage("current"), ) } - url = encodeURI(url) const encodedUrl = encodeURIComponent(url) return (