bigskysoftware / bigskysoftware/htmx
Links leading same hostname but another port incorrectly considered local
- Dominant language
- JavaScript
- Stars
- 49.4k
- Forks
- 1.7k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 30
Description
If a website hosted on (e.g.) http://localhost:3001 has an anchor element with the `href` being (e.g.) http://localhost:3002, the anchor will be considered local which enables boosting (if used). Since websites hosted on different ports (at least in the localhost case) usually are different websides (and them being [considered different origins](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#definition_of_an_origin), possibly causing CORS troubles) i believe this i a bug.
This i because `isLocalLink` compares the `hostname`s of `location` and the anchor element. I propose changing this to comparing the `origin`s instead.
Implementation is here: https://github.com/bigskysoftware/htmx/blob/f919c0705182c904a440e3ff4a9687f4d5166c55/src/htmx.js#L1407
Contributor guide
Assessment
This issue has not been assessed yet.