Jelajahi Sumber

Default correctly

Michelle Bu 11 tahun lalu
induk
melakukan
7a2fd81ccb
1 mengubah file dengan 9 tambahan dan 0 penghapusan
  1. 9 0
      lib/peer.js

+ 9 - 0
lib/peer.js

@@ -21,6 +21,7 @@ function Peer(id, options) {
     host: util.CLOUD_HOST,
     port: util.CLOUD_PORT,
     key: 'peerjs',
+    path: '/',
     config: util.defaultConfig
   }, options);
   this.options = options;
@@ -28,6 +29,14 @@ function Peer(id, options) {
   if (options.host === '/') {
     options.host = window.location.hostname;
   }
+  // Set path correctly.
+  if (options.path[0] !== '/') {
+    options.path = '/' + options.path;
+  }
+  if (options.path[options.path.length - 1] !== '/') {
+    options.path += '/';
+  }
+
   // Set whether we use SSL to same as current host
   if (options.secure === undefined && options.host !== util.CLOUD_HOST) {
     options.secure = util.isSecure();