diff --git a/Uri/UriFactory.js b/Uri/UriFactory.js index 6cfd4e1..74475f2 100644 --- a/Uri/UriFactory.js +++ b/Uri/UriFactory.js @@ -135,28 +135,29 @@ */ static unique (url) { - const parts = url.split('?'); + const parts = url.replace(/\?/g, '&').split('&'), + full = parts[0]; - if (parts.length >= 2) { - let full = parts[1], - pars = full.split('&'), - comps = {}, + if (parts.length > 1) { + parts.shift(); + + let comps = {}, spl = null, - length = pars.length; + length = parts.length; for (let i = 0; i < length; ++i) { - spl = pars[i].split('='); + spl = parts[i].split('='); comps[spl[0]] = spl[1]; } - pars = []; + let pars = []; for (let a in comps) { if (comps.hasOwnProperty(a)) { pars.push(a + '=' + comps[a]); } } - url = parts[0] + '?' + pars.join('&'); + url = full + '?' + pars.join('&'); } return url; diff --git a/tests/Uri/UriFactoryTest.js b/tests/Uri/UriFactoryTest.js index 36c77b5..bd7a8d4 100644 --- a/tests/Uri/UriFactoryTest.js +++ b/tests/Uri/UriFactoryTest.js @@ -60,7 +60,7 @@ describe('UriFactoryTest', function () { it('Testing global queries', function () { - let uri = 'www.test-uri.com?id={@ID}&test={.mTest}&two={/path}&hash={#hash}&none=#none&found={/not}&v={/valid2}', + let uri = 'www.test-uri.com?id={@ID}&test={.mTest}&two={/path}&hash={#hash}&none=#none&found={/not}?v={/valid2}', vars = { '@ID' : 1, '.mTest': 'someString',