Sfoglia il codice sorgente

transloadit: Remove startWith/endsWith use

Not supported in all browsers.
Renée Kooi 7 anni fa
parent
commit
307dbde557
1 ha cambiato i file con 5 aggiunte e 8 eliminazioni
  1. 5 8
      src/plugins/Transloadit/index.js

+ 5 - 8
src/plugins/Transloadit/index.js

@@ -185,18 +185,15 @@ module.exports = class Transloadit extends Plugin {
         // this is the criteria to identify remote files. If we add it without
         // the check, then the file automatically becomes a remote file.
         // @TODO: this is quite hacky. Please fix this later
-        let remote
+        let remote = file.remote
         if (file.remote) {
           let newHost = assembly.uppyserver_url
-          // remove tailing slash
-          if (newHost.endsWith('/')) {
-            newHost = newHost.slice(0, -1)
-          }
           let path = file.remote.url.replace(file.remote.host, '')
+          // remove tailing slash
+          newHost = newHost.replace(/\/$/, '')
           // remove leading slash
-          if (path.startsWith('/')) {
-            path = path.slice(1)
-          }
+          path = path.replace(/^\//, '')
+
           remote = Object.assign({}, file.remote, {
             host: newHost,
             url: `${newHost}/${path}`