Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fixup! fix($browser): normalize all optionally en/decoded characters …
Browse files Browse the repository at this point in the history
…when comparing URLs
  • Loading branch information
jbedard committed Oct 16, 2018
1 parent c8b94c8 commit eace1cb
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/ng/urlUtils.js
Expand Up @@ -4,11 +4,11 @@
// https://tools.ietf.org/html/rfc3986#appendix-A
var sub_delims = '!$&\'()*+,;=';
var alpha = 'abcdefghijklmnopqrstuvwxyz';
var digit = '0123456789'
var digit = '0123456789';
var unreserved = alpha + digit + '-._~';
var pchar = unreserved + sub_delims + ':' + '@'; //pct-encoded excluded
var query = (pchar + '/' + '?').replace(/[&=]/g, ''); //&= excluded
var fragment = pchar + '/' + '?';
var pchar = unreserved + sub_delims + ':@'; //pct-encoded excluded
var query = (pchar + '/?').replace(/[&=]/g, ''); //&= excluded
var fragment = pchar + '/?';

// Map of the encoded version of all characters not requiring encoding
var PATH_NON_ENCODED = charsToEncodedMap(pchar);
Expand Down Expand Up @@ -126,9 +126,15 @@ function urlResolve(url) {
// No browser normalizes all of the optionally encoded characters consistently.
// Various browsers normalize a subsets of the unreserved characters within the
// path, search and hash portions of the URL.
urlParsingNode.pathname = normalizeUriPath(urlParsingNode.pathname);
urlParsingNode.search = normalizeUriQuery(urlParsingNode.search.replace(/^\?/, ''));
urlParsingNode.hash = normalizeUriFragment(urlParsingNode.hash.replace(/^\#/, ''));
if (urlParsingNode.pathname) {
urlParsingNode.pathname = normalizeUriPath(urlParsingNode.pathname);
}
if (urlParsingNode.search) {
urlParsingNode.search = normalizeUriQuery(urlParsingNode.search.replace(/^\?/, ''));
}
if (urlParsingNode.hash) {
urlParsingNode.hash = normalizeUriFragment(urlParsingNode.hash.replace(/^#/, ''));
}

return {
href: urlParsingNode.href,
Expand Down

0 comments on commit eace1cb

Please sign in to comment.