diff options
-rw-r--r-- | src/uris.js | 7 | ||||
-rw-r--r-- | tests/urisTest.js | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/uris.js b/src/uris.js index 97ed4c42..6575b222 100644 --- a/src/uris.js +++ b/src/uris.js @@ -40,8 +40,11 @@ function parseAsCoordinateURL(url) { * the # as a work-around */ let uri = GLib.Uri.parse(url.replace('#map=', 'map='), GLib.UriFlags.NONE); - let params = GLib.Uri.parse_params(uri.get_query(), -1, '&', - GLib.UriParamsFlags.NONE); + let query = uri.get_query(); + let path = uri.get_path(); + // allow OSM location URLs encoding the location with or without a ? + let params = GLib.Uri.parse_params(query ?? path.replace('/', ''), -1, + '&', GLib.UriParamsFlags.NONE); let lat = params.lat; let lon = params.lon; diff --git a/tests/urisTest.js b/tests/urisTest.js index f7991ec8..4c08bfb8 100644 --- a/tests/urisTest.js +++ b/tests/urisTest.js @@ -62,6 +62,8 @@ function parseAsCoordinateURLTest() { URIS.parseAsCoordinateURL('https://www.openstreetmap.org/?lat=39.9882&lon=-78.2409&zoom=14&layers=B000FTF')); _assertArrayEquals([59.40538, 17.34894, 12], URIS.parseAsCoordinateURL('https://www.openstreetmap.org/?#map=12/59.40538/17.34894')); + _assertArrayEquals([59.3083, 18.0183, 16], + URIS.parseAsCoordinateURL('https://www.openstreetmap.org/#map=16/59.3083/18.0183')); } function parseMapsURITest() { |