mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-10 22:58:40 +00:00
Fix double ? in uri bug
This commit is contained in:
parent
1c642390e0
commit
edc596aba2
|
|
@ -135,28 +135,29 @@
|
||||||
*/
|
*/
|
||||||
static unique (url)
|
static unique (url)
|
||||||
{
|
{
|
||||||
const parts = url.split('?');
|
const parts = url.replace(/\?/g, '&').split('&'),
|
||||||
|
full = parts[0];
|
||||||
|
|
||||||
if (parts.length >= 2) {
|
if (parts.length > 1) {
|
||||||
let full = parts[1],
|
parts.shift();
|
||||||
pars = full.split('&'),
|
|
||||||
comps = {},
|
let comps = {},
|
||||||
spl = null,
|
spl = null,
|
||||||
length = pars.length;
|
length = parts.length;
|
||||||
|
|
||||||
for (let i = 0; i < length; ++i) {
|
for (let i = 0; i < length; ++i) {
|
||||||
spl = pars[i].split('=');
|
spl = parts[i].split('=');
|
||||||
comps[spl[0]] = spl[1];
|
comps[spl[0]] = spl[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
pars = [];
|
let pars = [];
|
||||||
for (let a in comps) {
|
for (let a in comps) {
|
||||||
if (comps.hasOwnProperty(a)) {
|
if (comps.hasOwnProperty(a)) {
|
||||||
pars.push(a + '=' + comps[a]);
|
pars.push(a + '=' + comps[a]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
url = parts[0] + '?' + pars.join('&');
|
url = full + '?' + pars.join('&');
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ describe('UriFactoryTest', function ()
|
||||||
{
|
{
|
||||||
it('Testing global queries', 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 = {
|
vars = {
|
||||||
'@ID' : 1,
|
'@ID' : 1,
|
||||||
'.mTest': 'someString',
|
'.mTest': 'someString',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user