URL fragment not handled properly when resolving short urls
Describe the bug
When a shortened URL contains a fragment identifier (ending with #-something), Finicky encodes that # as %23, which results in making it part of the actual URL, rather than a fragment.
Your configuration Nothing relevant.
To Reproduce Steps to reproduce the behavior:
- Open the link
https://bit.ly/3lsQ95cthrough Finicky (e.g. from the command line asopen 'https://bit.ly/3lsQ95c') - This should resolve to
https://github.com/johnste/finicky#table-of-contents(which is what it does if you enterhttps://bit.ly/3lsQ95cdirectly in your web browsers address bar). - But instead it resolves to
https://github.com/johnste/finicky%23table-of-contents, causing a 404 from GitHub.
I've worked around the issue for now with the following:
{
match: ({ url }) => url.host.endsWith("independentaustralia.net"),
url: ({ url }) => {
return {
...url,
host: url.host,
pathname: url.pathname.replace(/\%23.+/g, '')
}
}
}
Note that the workaround assumes that the shortened URL only can contain non-encoded #.
Wouldn't be it easier to use decodeURI(url) in return? (or something similar)?
I mean it would probably be better to fix the underlying bug...
Personally I'd be fine if Finicky merely resolved URL shorteners in order to decide which browser to use but then still gave the original short URL to the browser.
That would be an excellent solution.
Alternatively, looks like perhaps taking the calls to addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) and adding # to the .urlQueryAllowed character set would work?