3 ms·
However, the JS gettters are all over the place... Given this: a = document.createElement('a') a.href = "/ö/o?ö/o#ö/o" console.log(a.hash, a.pathn
by pygy_ 10y ago
However, the JS gettters are all over the place...
Given this:
a = document.createElement('a')
a.href = "/ö/o?ö/o#ö/o"
console.log(a.hash, a.pathname, a.search)
we get:
Browser .hash .pathname .search
Chrome #ö/o /%C3%B6/o ?%C3%B6/o
Firefox #%C3%B6/o /%C3%B6/o ?%C3%B6/o
Safari #%C3%B6/o /%C3%B6/o ?%C3%B6/o
Edge #ö/o /ö/o ?ö/o
IE11 #ö/o ö/o (ouch) ?ö/o
Likewise for domains, some UAs return them Punycoded (but don't provide a decoder), some in Unicode, and PhantomJS passes it percent encoded...
It's a big mess.
I discovered this while working on a SPA router that can handle routes in either `pathname`, `search` or `hash` mode... The routes are defined as the keys of a JS object, in Unicode in the source, and we have to juggle back and forth to match what `document.location.*` returns.
- kmike84 10y agoIt looks like Developer tools also use these JS utilities, so you can't trust Network tab when checking what URL is sent to a remote server; to check what's being sent one have to either inspect network traffic or check it server side.