ensure replaced 'http' is at beginning of url or not replaced

This commit is contained in:
Zane Hitchcox 2017-02-14 16:04:40 -05:00
parent 3a6708c9a7
commit 3e77509084
2 changed files with 3 additions and 3 deletions

4
gun.js
View File

@ -2237,7 +2237,7 @@
// Ensure the protocol is correct. // Ensure the protocol is correct.
Client.formatURL = function (url) { Client.formatURL = function (url) {
return url.replace('http', 'ws'); return url.replace(/^http/, 'ws');
}; };
// Send a message to a group of peers. // Send a message to a group of peers.
@ -2457,4 +2457,4 @@
module.exports = Client; module.exports = Client;
})(require, './polyfill/request'); })(require, './polyfill/request');
}()); }());

View File

@ -120,7 +120,7 @@ function Peer (url, options) {
Peer.formatURL = function (url) { Peer.formatURL = function (url) {
// Works for `https` and `wss` URLs, too. // Works for `https` and `wss` URLs, too.
return url.replace('http', 'ws'); return url.replace(/^http/, 'ws');
}; };
util.inherits(Peer, Emitter); util.inherits(Peer, Emitter);