Browse Source

fix: avoid double slash cc @kvz

Ifedapo Olarewaju 7 years ago
parent
commit
4ff1898465
1 changed files with 11 additions and 2 deletions
  1. 11 2
      src/plugins/Transloadit/index.js

+ 11 - 2
src/plugins/Transloadit/index.js

@@ -175,10 +175,19 @@ module.exports = class Transloadit extends Plugin {
         // @TODO: this is quite hacky. Please fix this later
         let remote
         if (file.remote) {
-          const newHost = assembly.uppyserver_url
+          let newHost = assembly.uppyserver_url
+          // remove tailing slash
+          if (newHost.endsWith('/')) {
+            newHost = newHost.splice(0, -1)
+          }
+          let path = file.remote.url.replace(file.remote.host, '')
+          // remove leading slash
+          if (path.startsWith('/')) {
+            path = path.slice(1)
+          }
           remote = Object.assign({}, file.remote, {
             host: newHost,
-            url: file.remote.url.replace(file.remote.host, newHost)
+            url: `${newHost}/${path}`
           })
         }