diff --git a/src/uris.js b/src/uris.js index 97ed4c42cadbc08fc376c81762c612405ff54041..6575b22255b3e4123b68113979b8515bc544fec7 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 f7991ec834f546e9d6b327324045365bf33afa00..4c08bfb8d270256bb29bead0e5f0ec6583d1e3d2 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() {