mirror of
https://github.com/DIYgod/RSSHub-Radar.git
synced 2026-08-28 17:45:13 +08:00
fix: don't encode url for copy, support route param with regex (#1017)
* fix: don't encode url for copy * fix: always rendering * fix: support route with regex
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user