You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Trailing slash added to urls in href when using linkedom #980
The string is parsed into a document using linkedom version 0.18.12. Inspecting the Node objects show the href as expected, without a slash.
Creating a new readability object and using the parse method however, generates an object with the href url having a newly added trailing slash. In this example, such a change leads to a 404 not found exception.
@richardklapac Does the same issue occur when using jsdom? I cannot reproduce when using jsdom, so I suspect this is a linkedom bug. If it's straightforward enough, I would take a patch that avoids this somehow, but to do that we'd need to know what exactly linkedom is doing and where readability is tripping up.
generates an object with the href url having a newly added trailing slash
To be clear, you're saying that the output in this case has a element's href manipulated?
I can't use jsdom at the moment, as the project is not in Node. If we can't pinpoint the linkedom/readability cause, I'll try to reproduce in a Node environment with jsdom as well. In the meantime:
Yes, it seems that the a element's href is manipulated.
Here is my minimal code, using the example provided:
consthtml=`<!DOCTYPE HTML"><html><body><a href="/api/browser/proxy?url=https%3A%2F%2Fwww.debian.org%2Fsecurity%2Ffaq">https://www.debian.org/security/faq</a></body></html>`console.log(html)// contains correct /faq without a trailing slashconstparser=newDOMParser();constdoc=parser.parseFromString(html,'text/html');console.log(doc.getElementsByTagName("a")[0])// contains correct /faq without a trailing slashconsole.log(newReadability(doc).parse()!.content)// contains incorrect /faq/ with a trailing slash
First log output is the example HTML.
Second log output, sorry for the screenshot, React Native devs had the bright idea to force all logs to go through chrome, not cli, and I have no idea how to copy the raw value:
Activity
gijsk commentedon Sep 24, 2025
@richardklapac Does the same issue occur when using
jsdom? I cannot reproduce when usingjsdom, so I suspect this is a linkedom bug. If it's straightforward enough, I would take a patch that avoids this somehow, but to do that we'd need to know what exactly linkedom is doing and where readability is tripping up.To be clear, you're saying that the output in this case has
aelement's href manipulated?richardklapac commentedon Sep 26, 2025
I can't use jsdom at the moment, as the project is not in Node. If we can't pinpoint the linkedom/readability cause, I'll try to reproduce in a Node environment with jsdom as well. In the meantime:
Yes, it seems that the
aelement's href is manipulated.Here is my minimal code, using the example provided:
First log output is the example HTML.
Second log output, sorry for the screenshot, React Native devs had the bright idea to force all logs to go through chrome, not cli, and I have no idea how to copy the raw value:
Third log output:
[-]Trailing slash added to urls in href[/-][+]Trailing slash added to urls in href when using linkedom[/+]