fix coordinate search with / symbol (#10879)

This commit is contained in:
dragoon
2025-03-15 00:01:04 +05:30
committed by GitHub
parent 58ab8200d6
commit e6c379053e
2 changed files with 9 additions and 1 deletions

View File

@@ -214,6 +214,14 @@ export function dmsMatcher(q, _localeCode = undefined) {
return [isNegLat, isNegLng];
}
},
// D/D ex: 46.112785/72.921033
{
condition: /^\s*(-?\d+\.?\d*)\s*\/\s*(-?\d+\.?\d*)\s*$/,
parser: function(q) {
const match = this.condition.exec(q);
return [+match[1], +match[2]];
}
},
// zoom/x/y ex: 2/1.23/34.44
{
condition: /^\s*(\d+\.?\d*)\s*\/\s*(-?\d+\.?\d*)\s*\/\s*(-?\d+\.?\d*)\s*$/,

View File

@@ -28,7 +28,7 @@ describe('iD.units', function() {
expect(result[2]).to.eql(2);
});
it('parses x/y coordinate', () => {
var result = iD.dmsMatcher('-1.23/34.44');
var result = iD.dmsMatcher('-1.23/34.44', 'de');
expect(result[0]).to.be.closeTo(-1.23, 0.00001);
expect(result[1]).to.be.closeTo(34.44, 0.00001);
});