|
@@ -12,6 +12,10 @@ function defaultGetAssemblyOptions (file, options) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const UPPY_SERVER = 'https://api2.transloadit.com/uppy-server'
|
|
|
+
|
|
|
+const TL_UPPY_SERVER = /https?:\/\/api2(?:-\w+)?\.transloadit\.com\/uppy-server/
|
|
|
+
|
|
|
|
|
|
* Upload files to Transloadit using Tus.
|
|
|
*/
|
|
@@ -181,23 +185,19 @@ module.exports = class Transloadit extends Plugin {
|
|
|
endpoint: assembly.tus_url
|
|
|
})
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- let remote
|
|
|
- if (file.remote) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let remote = file.remote
|
|
|
+ if (file.remote && TL_UPPY_SERVER.test(file.remote)) {
|
|
|
let newHost = assembly.uppyserver_url
|
|
|
-
|
|
|
- if (newHost.endsWith('/')) {
|
|
|
- newHost = newHost.slice(0, -1)
|
|
|
- }
|
|
|
let path = file.remote.url.replace(file.remote.host, '')
|
|
|
+
|
|
|
+ newHost = newHost.replace(/\/$/, '')
|
|
|
|
|
|
- if (path.startsWith('/')) {
|
|
|
- path = path.slice(1)
|
|
|
- }
|
|
|
+ path = path.replace(/^\//, '')
|
|
|
+
|
|
|
remote = Object.assign({}, file.remote, {
|
|
|
host: newHost,
|
|
|
url: `${newHost}/${path}`
|
|
@@ -860,3 +860,5 @@ module.exports = class Transloadit extends Plugin {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+module.exports.UPPY_SERVER = UPPY_SERVER
|