Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't encode url for copy, support route param with regex #1017

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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