-
Notifications
You must be signed in to change notification settings - Fork 79
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
Double encoding of anchor tag href #188
Comments
this is weird to fix because AFAIK the |
Imagine an anchor tag pointing to a file. This file has space characters in its filename which means the " " character will already be encoded as "%20". For example: <a href="https://www.westonpriory.org/esales/lyrics/Something%20Which%20Is%20Known.pdf"></a> When I add the following test to a.setAttribute('href', 'https://www.westonpriory.org/esales/lyrics/Something%20Which%20Is%20Known.pdf');
assert(a.href, 'https://www.westonpriory.org/esales/lyrics/Something%20Which%20Is%20Known.pdf'); I would expect to get the same link because otherwise the link is broken.
I opened a PR to fix this: #204. |
Agreed and I hate double encoding/decoding shenanigans myself ... the thing I am not understanding is where that string gets encoded in the first place and, in case I really want to write manually a url with |
I am thinking mainly of file servers that serve static files and If you have concerns I can also just use the workaround that I mentioned in the issue to move that logic outside of the library but then, in my case, the library would not have the same behavior as regular DOM queries. |
Hey,
I've been using your amazing library to extract links from DOM content in a service worker and noticed that achor tags which, for example, lead to some file which has already encoded space characters in the URL (
www.test.com/path%20to%20some%20file.pdf
) end up with a brokenhref
because the%
character is encoded again (www.test.com/path%2520to%2520some%2520file.pdf
).I have a workaround by just calling
decodeURIComponent
on thehref
attribute before processing it but I guess that is not the intended behavior and shouldn't be like that.I am sure that it's related to #49 and the fix for it here
linkedom/cjs/html/anchor-element.js
Line 18 in 5b31c58
I would guess and hope it's not a complicated fix.
Thanks a lot for your work!
The text was updated successfully, but these errors were encountered: