Board Thread:General Coding Help/@comment-9605025-20180428232938/@comment-9605025-20180501105754

Okay, another question. Is it considered bad practice to do encodeURIComponent(decodeURIComponent(location.pathname)); I ask because one issue I am having is that, depending on the specifics of the URL, some web browsers automatically encode some but not all characters. This is causing a problem because, if I just encode straight from the string, some characters get double-encoded. For example, if the pathname is "/wiki/This is/a_test/Subpage" and there is no query string or anchor, it will get converted to "/wiki/This_is/a_test/Subpage". However, if there is an anchor or query string, it will get converted to "/wiki/This%20is/a_test/Subpage". In the latter case, if I encode that value, I then get "%2Fwiki%2FThis%2520is%2Fa_test%2FSubpage". Decoding that then gives me "/wiki/This%20is/a_test/Subpage" which is then flagged as an invalid page name when trying to create the page.