mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-22 00:07:03 +02:00
Have utilStringQs advance past any leading '?' or '#' characters
This lets us remove a bunch of substring(1) and +1 from the code.
This commit is contained in:
@@ -21,7 +21,7 @@ describe('iD.serviceNominatim', function() {
|
||||
});
|
||||
|
||||
function query(url) {
|
||||
return iD.utilStringQs(url.substring(url.indexOf('?') + 1));
|
||||
return iD.utilStringQs(url.substring(url.indexOf('?')));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
|
||||
|
||||
function query(url) {
|
||||
return iD.utilStringQs(url.substring(url.indexOf('?') + 1));
|
||||
return iD.utilStringQs(url.substring(url.indexOf('?')));
|
||||
}
|
||||
|
||||
function adjust(params, data) {
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('iD.serviceTaginfo', function() {
|
||||
});
|
||||
|
||||
function query(url) {
|
||||
return iD.utilStringQs(url.substring(url.indexOf('?') + 1));
|
||||
return iD.utilStringQs(url.substring(url.indexOf('?')));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ for (var k in iD.services) { delete iD.services[k]; }
|
||||
|
||||
// Run without data for speed (tests which need data can set it up themselves)
|
||||
|
||||
// Initializing `coreContext` will try loading the English locale strings:
|
||||
iD.data.locale_en = { en: {} };
|
||||
// Initializing `coreContext` initializes `_background`, which tries loading:
|
||||
iD.data.imagery = [];
|
||||
// Initializing `coreContext` initializes `_presets`, which tries loading:
|
||||
|
||||
+20
-3
@@ -79,9 +79,26 @@ describe('iD.util', function() {
|
||||
});
|
||||
|
||||
it('utilStringQs', function() {
|
||||
expect(iD.utilStringQs('foo=bar')).to.eql({foo: 'bar'});
|
||||
expect(iD.utilStringQs('foo=bar&one=2')).to.eql({foo: 'bar', one: '2' });
|
||||
expect(iD.utilStringQs('')).to.eql({});
|
||||
it('splits a parameter string into k=v pairs', function() {
|
||||
expect(iD.utilStringQs('foo=bar')).to.eql({foo: 'bar'});
|
||||
expect(iD.utilStringQs('foo=bar&one=2')).to.eql({foo: 'bar', one: '2' });
|
||||
expect(iD.utilStringQs('')).to.eql({});
|
||||
});
|
||||
it('trims leading # if present', function() {
|
||||
expect(iD.utilStringQs('#foo=bar')).to.eql({foo: 'bar'});
|
||||
expect(iD.utilStringQs('#foo=bar&one=2')).to.eql({foo: 'bar', one: '2' });
|
||||
expect(iD.utilStringQs('#')).to.eql({});
|
||||
});
|
||||
it('trims leading ? if present', function() {
|
||||
expect(iD.utilStringQs('?foo=bar')).to.eql({foo: 'bar'});
|
||||
expect(iD.utilStringQs('?foo=bar&one=2')).to.eql({foo: 'bar', one: '2' });
|
||||
expect(iD.utilStringQs('?')).to.eql({});
|
||||
});
|
||||
it('trims leading #? if present', function() {
|
||||
expect(iD.utilStringQs('#?foo=bar')).to.eql({foo: 'bar'});
|
||||
expect(iD.utilStringQs('#?foo=bar&one=2')).to.eql({foo: 'bar', one: '2' });
|
||||
expect(iD.utilStringQs('#?')).to.eql({});
|
||||
});
|
||||
});
|
||||
|
||||
it('utilQsString', function() {
|
||||
|
||||
Reference in New Issue
Block a user