diff --git a/js/id/renderer/hash.js b/js/id/renderer/hash.js index 4365a1515..05691ef59 100644 --- a/js/id/renderer/hash.js +++ b/js/id/renderer/hash.js @@ -4,16 +4,8 @@ iD.Hash = function() { lat = 90 - 1e-8, // allowable latitude range map; - function qs(str) { - return str.split('&').reduce(function(obj, pair){ - var parts = pair.split('='); - obj[parts[0]] = (null === parts[1]) ? '' : decodeURIComponent(parts[1]); - return obj; - }, {}); - } - var parser = function(map, s) { - var q = qs(s); + var q = iD.util.stringQs(s); var args = (q.map || '').split("/").map(Number); if (args.length < 3 || args.some(isNaN)) { return true; // replace bogus hash diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index 7aa10cd23..a00327aa3 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -6,7 +6,6 @@ iD.Map = function() { selection = null, translateStart, keybinding, - apiTilesLoaded = {}, projection = d3.geo.mercator(), zoom = d3.behavior.zoom() .translate(projection.translate()) diff --git a/js/id/util.js b/js/id/util.js index 08cf6a635..2c83d96b8 100644 --- a/js/id/util.js +++ b/js/id/util.js @@ -50,6 +50,14 @@ iD.util.tagText = function(entity) { }).join('\n'); }; +iD.util.stringQs = function(str) { + return str.split('&').reduce(function(obj, pair){ + var parts = pair.split('='); + obj[parts[0]] = (null === parts[1]) ? '' : decodeURIComponent(parts[1]); + return obj; + }, {}); +}; + iD.util.qsString = function(obj) { return Object.keys(obj).sort().map(function(key) { return encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]); diff --git a/test/spec/util.js b/test/spec/util.js index 8a23b131a..6c47a98aa 100644 --- a/test/spec/util.js +++ b/test/spec/util.js @@ -39,15 +39,13 @@ describe('Util', function() { it('correctly says that a node is in an extent', function() { expect(iD.util.geo.nodeIntersect({ lat: 0, lon: 0 - }, [ - [-180, 90], + }, [[-180, 90], [180, -90]])).to.be.true; }); it('correctly says that a node is outside of an extent', function() { expect(iD.util.geo.nodeIntersect({ lat: 0, lon: 0 - }, [ - [100, 90], + }, [[100, 90], [180, -90]])).to.be.false; }); });