Gracefully ignore exceptions when trying to register the ProtocolHandler

This commit is contained in:
Dennis Schubert 2018-07-13 00:04:41 +02:00 committed by Benjamin Neff
parent 8709c45d30
commit f8a4a2c510
No known key found for this signature in database
GPG key ID: 971464C3F1A90194

View file

@ -2,19 +2,20 @@
Diaspora.ProtocolHandler = { Diaspora.ProtocolHandler = {
register: function() { register: function() {
if (typeof (window.navigator.registerProtocolHandler) !== "function") { if (!window.navigator.registerProtocolHandler) {
return false; return false;
} }
var protocol = location.protocol; try {
var slashes = protocol.concat("//"); window.navigator.registerProtocolHandler(
var host = slashes.concat(window.location.hostname); "web+diaspora",
[window.location.protocol, "//", window.location.host, "/link?q=%s"].join(""),
if (location.port) { document.title
host = host.concat(":" + location.port); );
} catch (_) {
return false;
} }
window.navigator.registerProtocolHandler("web+diaspora", host.concat("/link?q=%s"), document.title);
return true; return true;
} }
}; };