finicky icon indicating copy to clipboard operation
finicky copied to clipboard

URL fragment not handled properly when resolving short urls

Open thobe opened this issue 4 years ago • 6 comments

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:

  1. Open the link https://bit.ly/3lsQ95c through Finicky (e.g. from the command line as open 'https://bit.ly/3lsQ95c')
  2. This should resolve to https://github.com/johnste/finicky#table-of-contents (which is what it does if you enter https://bit.ly/3lsQ95c directly in your web browsers address bar).
  3. But instead it resolves to https://github.com/johnste/finicky%23table-of-contents, causing a 404 from GitHub.

thobe avatar Mar 18 '21 08:03 thobe

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, '')
				}
			}
		}

jtrott avatar Dec 15 '21 05:12 jtrott

Note that the workaround assumes that the shortened URL only can contain non-encoded #.

glasser avatar Feb 28 '23 18:02 glasser

Wouldn't be it easier to use decodeURI(url) in return? (or something similar)?

sashkab avatar Feb 28 '23 21:02 sashkab

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.

glasser avatar Feb 28 '23 23:02 glasser

That would be an excellent solution.

jtrott avatar Mar 01 '23 00:03 jtrott

Alternatively, looks like perhaps taking the calls to addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) and adding # to the .urlQueryAllowed character set would work?

glasser avatar Mar 01 '23 05:03 glasser