Closed Ricardo-Silva91 closed 5 years ago
decodeURIComponent()
can result in issues as it's been around, mostly untouched (supposedly) since JavaScript's beginnings. It might be best to wait to fix this along with #45. ~If not, this PR looks fine otherwise.~~
I just noticed something:
normalizeUrl('http://host/?var1=va%26lue&var2=value');
results in
http://host/?var1=va&lue&var2=value
which is a different URL.
Hello again. The latest commit has a fix for the bug @stevenvachon noticed (character '&' inside a parameter splits the parameter in 2). With this hotfix, the complexity of the function increased to 23, not sure if that's a problem. I also added a test for the bug.
Closing as we no longer decode the URL.
Fixes #43: '@' symbol not being decoded from '%40' used the decodeURIComponent() method. Maybe it's too general but, since the code still passes all previous tests, I suppose it's preferable to just replacing the '@' character with str.replace(/%40/, '@'), as it can prevent future similar issues.