summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcus Lundblad <ml@update.uu.se>2022-02-07 22:07:53 +0100
committerMarcus Lundblad <ml@update.uu.se>2022-02-07 22:35:50 +0100
commita109d938ff55412744da0341c75888aa29f90bd4 (patch)
tree1ec240e70ca1975e810be641f239a7a746b9fcac /src
parentc5652e22ac2fb6ced42c8ce49e0de4c83c87b761 (diff)
downloadgnome-maps-a109d938ff55412744da0341c75888aa29f90bd4.tar.gz
uris: Accept OSM location URLs without ?wip/mlundblad/osm-location-url-no-qm
Sometimes shared URLs pointing to a location in OSM is on the form https://www.openstreetmap.org/#map=... E.g. encoding the parameters as part of the path instead of a query. Accept both variants, and add an additional test case.
Diffstat (limited to 'src')
-rw-r--r--src/uris.js7
1 files changed, 5 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;