[openstreetmap/openstreetmap-website] Add geo URI handler registration on link interaction (PR #5968)
Pablo Brasero
notifications at github.com
Thu Oct 2 14:13:41 UTC 2025
@pablobm commented on this pull request.
> + if (sessionStorage.getItem("wasAbleToAskForHandler")) return;
+ try {
+ navigator.registerProtocolHandler("geo", "/?geouri=%s");
+ sessionStorage.setItem("wasAbleToAskForHandler", "yes");
+ } catch (e) {
+ sessionStorage.setItem("wasAbleToAskForHandler", "no");
+ }
How about this instead?
- It avoids handling the success and error cases separately.
- Uses a boolean instead of a "yes"/"no" string, which I think is more natural.
- Uses a more specific name, just in case we want to ask for other handlers in the future.
```suggestion
if (sessionStorage.getItem("askedForGeoProtocolHandler")) return;
try {
navigator.registerProtocolHandler("geo", "/?geouri=%s");
} finally {
sessionStorage.setItem("askedForGeoProtocolHandler", true);
}
```
> @@ -226,6 +228,16 @@ L.OSM.share = function (options) {
const precision = 5 * Math.pow(10, Math.floor(Math.LOG10E * Math.log(scale)) - 2);
return precision * Math.ceil(scale / precision);
}
+
+ function askToHandleGeoURI() {
+ if (sessionStorage.getItem("wasAbleToAskForHandler")) return;
+ try {
+ navigator.registerProtocolHandler("geo", "/?geouri=%s");
+ sessionStorage.setItem("wasAbleToAskForHandler", "yes");
+ } catch (e) {
+ sessionStorage.setItem("wasAbleToAskForHandler", "no");
Sorry, I mean why use yes/no instead of a boolean. Hang on, I'm going to do an "add a suggestion" instead to illustrate... (Closing this thread and picking up in a new one).
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5968#pullrequestreview-3294854158
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5968/review/3294854158 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20251002/ca37f4b0/attachment.htm>
More information about the rails-dev
mailing list