Browse Source

No more fullpath needed

Michelle Bu 11 năm trước cách đây
mục cha
commit
13cab95b3a
2 tập tin đã thay đổi với 3 bổ sung9 xóa
  1. 1 5
      lib/peer.js
  2. 2 4
      lib/socket.js

+ 1 - 5
lib/peer.js

@@ -116,7 +116,7 @@ Peer.prototype._retrieveId = function(cb) {
   var self = this;
   var http = new XMLHttpRequest();
   var protocol = this.options.secure ? 'https://' : 'http://';
-  var url = protocol + this.options.host + ':' + this.options.port + '/' + this._fullPath() + this.options.key + '/id';
+  var url = protocol + this.options.host + ':' + this.options.port + this.options.path + this.options.key + '/id';
   var queryString = '?ts=' + new Date().getTime() + '' + Math.random();
   url += queryString;
 
@@ -237,10 +237,6 @@ Peer.prototype._handleMessage = function(message) {
   }
 }
 
-Peer.prototype._fullPath = function() {
-  return this.options.path ? this.options.path + '/' : '';
-}
-
 /** Stores messages without a set up connection, to be claimed later. */
 Peer.prototype._storeMessage = function(connectionId, message) {
   if (!this._lostMessages[connectionId]) {

+ 2 - 4
lib/socket.js

@@ -13,10 +13,8 @@ function Socket(secure, host, port, path, key) {
 
   var httpProtocol = secure ? 'https://' : 'http://';
   var wsProtocol = secure ? 'wss://' : 'ws://';
-  this._httpUrl = httpProtocol + host + ':' + port + '/'
-    + (path ? path + '/' : '') + key;
-  this._wsUrl = wsProtocol + host + ':' + port + '/'
-    + (path ? path + '/' : '') + 'peerjs?key=' + key;
+  this._httpUrl = httpProtocol + host + ':' + port + path + key;
+  this._wsUrl = wsProtocol + host + ':' + port + path + 'peerjs?key=' + key;
 }
 
 util.inherits(Socket, EventEmitter);