Last Updated: February 25, 2016
·
4.385K
· lrsjng

document.location.pathname not the same in all browsers

While Chrome and Firefox return the encoded pathname, Safari and Opera do return a decoded pathname.

For example "http://domain.tld/test%20url/" will become "/test%20url/" in Chrome etc. but "/test url/" in Safari.

Safari even decodes document.location.href, while none of the other three do.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside