htmx icon indicating copy to clipboard operation
htmx copied to clipboard

Links leading same hostname but another port incorrectly considered local

Open foodelevator opened this issue 1 year ago • 0 comments

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, possibly causing CORS troubles) i believe this i a bug.

This i because isLocalLink compares the hostnames of location and the anchor element. I propose changing this to comparing the origins instead.

Implementation is here: https://github.com/bigskysoftware/htmx/blob/f919c0705182c904a440e3ff4a9687f4d5166c55/src/htmx.js#L1407

foodelevator avatar Feb 25 '24 15:02 foodelevator