Explorar o código

Resolve some issues with parent directories at the top of a url path

Jason Grout %!s(int64=4) %!d(string=hai) anos
pai
achega
470964a5bb
Modificáronse 1 ficheiros con 3 adicións e 6 borrados
  1. 3 6
      packages/coreutils/src/url.ts

+ 3 - 6
packages/coreutils/src/url.ts

@@ -46,12 +46,9 @@ export namespace URLExt {
   export function join(...parts: string[]): string {
     const first = urlparse(parts[0], {});
     const prefix = `${first.protocol}${first.slashes ? '//' : ''}${first.auth}${first.host}`;
-    let path = posix.join(first.pathname, ...parts.slice(1));
-    if (path === '.') {
-      path = '';
-    }
-    // Put in a slash between the prefix and path if needed
-    return `${prefix}${!!prefix && !!path && path[0] !== '/' ? '/' : ''}${path}`;
+    // If there was a prefix, then the first path must start at the root.
+    const path = posix.join(`${!!prefix && first.pathname[0] !== '/' ? '/' : ''}${first.pathname}`, ...parts.slice(1));
+    return `${prefix}${path === '.' ? '' : path}`;
   }
 
   /**