diff --git a/gun.js b/gun.js index bc12ff7d..6936b930 100644 --- a/gun.js +++ b/gun.js @@ -2237,7 +2237,7 @@ // Ensure the protocol is correct. Client.formatURL = function (url) { - return url.replace('http', 'ws'); + return url.replace(/^http/, 'ws'); }; // Send a message to a group of peers. @@ -2457,4 +2457,4 @@ module.exports = Client; })(require, './polyfill/request'); -}()); \ No newline at end of file +}()); diff --git a/lib/wsp/Peer.js b/lib/wsp/Peer.js index 11f1069c..2b9dffed 100644 --- a/lib/wsp/Peer.js +++ b/lib/wsp/Peer.js @@ -120,7 +120,7 @@ function Peer (url, options) { Peer.formatURL = function (url) { // Works for `https` and `wss` URLs, too. - return url.replace('http', 'ws'); + return url.replace(/^http/, 'ws'); }; util.inherits(Peer, Emitter);