diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index 8c139dc40..563bbc315 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -46,3 +46,4 @@ //= require bootstrap-markdown/bootstrap-markdown //= require helpers/markdown_editor //= require jquery.are-you-sure +//= require protocol-handler diff --git a/app/assets/javascripts/protocol-handler.js b/app/assets/javascripts/protocol-handler.js new file mode 100644 index 000000000..6afedf409 --- /dev/null +++ b/app/assets/javascripts/protocol-handler.js @@ -0,0 +1,17 @@ +// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later + +function registerDiasporaLinksProtocol() { + var protocol = location.protocol; + var slashes = protocol.concat("//"); + var host = slashes.concat(window.location.hostname); + + if (location.port) { + host = host.concat(":" + location.port); + } + + window.navigator.registerProtocolHandler("web+diaspora", host.concat("/link?q=%s"), document.title); +} + +if (typeof (window.navigator.registerProtocolHandler) === "function") { + registerDiasporaLinksProtocol(); +}