Bladeren bron

Update uppy.js

Make companion be able to handle multiple server in different paths.
Tran Van Sang 6 jaren geleden
bovenliggende
commit
40d1310eac
1 gewijzigde bestanden met toevoegingen van 3 en 5 verwijderingen
  1. 3 5
      packages/@uppy/companion/src/uppy.js

+ 3 - 5
packages/@uppy/companion/src/uppy.js

@@ -105,7 +105,7 @@ module.exports.app = (options = {}) => {
  *
  * @param {object} server
  */
-module.exports.socket = (server, option) => {
+module.exports.socket = (server) => {
   const wss = new SocketServer({ server })
   const redisClient = redis.client()
 
@@ -114,12 +114,10 @@ module.exports.socket = (server, option) => {
   // client attempts to reconnect.
   wss.on('connection', (ws) => {
     // @ts-ignore
-    let fullPath = ws.upgradeReq.url
-    if (option && option.server && option.server.path && fullPath.startsWith(option.server.path))
-      fullPath = fullPath.slice(option.server.path.length)
+    const fullPath = ws.upgradeReq.url
     // the token identifies which ongoing upload's progress, the socket
     // connection wishes to listen to.
-    const token = fullPath.replace(/\/api\//, '')
+    const token = fullPath.replace(/^.*\/api\//, '')
     logger.info(`connection received from ${token}`, 'socket.connect')
 
     /**