Browse Source

fix companion implicitpath (#4484)

* fix undefined protocol and example page

fixes #4478

* fix companion implicitpath

fixes #4468
Mikael Finstad 1 year ago
parent
commit
ae49999472
1 changed files with 14 additions and 10 deletions
  1. 14 10
      packages/@uppy/companion/src/server/helpers/utils.js

+ 14 - 10
packages/@uppy/companion/src/server/helpers/utils.js

@@ -41,24 +41,28 @@ module.exports.getURLBuilder = (options) => {
   /**
    * Builds companion targeted url
    *
-   * @param {string} path the tail path of the url
+   * @param {string} subPath the tail path of the url
    * @param {boolean} isExternal if the url is for the external world
    * @param {boolean} [excludeHost] if the server domain and protocol should be included
    */
-  const buildURL = (path, isExternal, excludeHost) => {
-    let url = path
-    // supports for no path specified too
-    if (isExternal) {
-      url = `${options.server.implicitPath || ''}${url}`
+  const buildURL = (subPath, isExternal, excludeHost) => {
+    let path = ''
+
+    if (isExternal && options.server.implicitPath) {
+      path += options.server.implicitPath
+    }
+
+    if (options.server.path) {
+      path += options.server.path
     }
 
-    url = `${options.server.path || ''}${url}`
+    path += subPath
 
-    if (!excludeHost) {
-      url = `${options.server.protocol}://${options.server.host}${url}`
+    if (excludeHost) {
+      return path
     }
 
-    return url
+    return `${options.server.protocol}://${options.server.host}${path}`
   }
 
   return buildURL