lemmy-ui
lemmy-ui copied to clipboard
Add a lemmy protocol handler
There's also protocol handlers.
On your home instance, lemmy-ui (or your favourite app would register itself as a
web+lemmy:protocol handler. In JS this looks likenavigator.registerProtocolHandler("web+lemmy", "https://lemmy.world/resolve?url=%s", "Lemmy cross-instance link handler")On firefox, this results in a prompt like this:
On chrome like this:
Now, all links to
web+lemmy:...will go to your home instance (or app on android).Every lemmy-ui would have a button "Open on my local instance". The button is a href to
web+lemmy:https://<post/comment/community/user url>.Edit: I think there's multiple sparate issues being discussed in this issue. I'm making it worse. Probably would make sense to split it out more or make it more generic
Originally posted by @phiresky in #2987
Looks like this needs to be done in frontends, by calling registerProtocolHandler(scheme, url)
Safari, Chrome for Android and others don't support it.
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler#browser_compatibility
EDIT: I guess you register the protocol handler first and then all your links have to use that without hostname or protocol
does web+lemmy:https://retrolemmy.com/whatever work when not registered or only when you have a registered handler? I used inspect element to modify an href into that format but it didn't work (Chrome, Windows)
maybe javascript could do something to detect it but I don't see a method for checking if a protocol handler is registered
Failed to launch 'web+lemmy:https://developer.mozilla.org/' because the scheme does not have a registered handler.
Maybe javascript can catch that exception and open the regular link, but I didn't try putting this in an onclick event
I also didn't try Firefox yet, but this could definitely be something based on which browser is detected
This is related to Instance agnostic links which are already implemented in the backend. So its not necessary anymore.