Przeglądaj źródła

added fix for auth case

Alex Bozarth 4 lat temu
rodzic
commit
984479ff7b

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

@@ -45,7 +45,9 @@ export namespace URLExt {
    */
   export function join(...parts: string[]): string {
     const u = urlparse(parts[0], {});
-    const prefix = `${u.protocol}${u.slashes ? '//' : ''}${u.auth}${u.host}`;
+    const prefix = `${u.protocol}${u.slashes ? '//' : ''}${u.auth}${
+      u.auth ? '@' : ''
+    }${u.host}`;
     // If there was a prefix, then the first path must start at the root.
     const path = posix.join(
       `${!!prefix && u.pathname[0] !== '/' ? '/' : ''}${u.pathname}`,

+ 3 - 0
packages/coreutils/test/url.spec.ts

@@ -43,6 +43,9 @@ describe('@jupyterlab/coreutils', () => {
         expect(URLExt.join('http://www.example.com/', '/bar')).toBe(
           'http://www.example.com/bar'
         );
+        expect(URLExt.join('http://user:pass@www.example.com/', '/bar')).toBe(
+          'http://user:pass@www.example.com/bar'
+        );
         expect(URLExt.join('//example.com', 'foo:bar:', 'baz')).toBe(
           '//example.com/foo:bar:/baz'
         );