From fd57079ac8ac597b31c4e5f3dd56a2d39eae20a6 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 27 Jun 2022 12:38:52 +0100 Subject: [PATCH] fix: replace double-slashes in `join` calls (#17) --- src/path.ts | 2 +- test/index.spec.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/path.ts b/src/path.ts index a61bee0..f295bd5 100644 --- a/src/path.ts +++ b/src/path.ts @@ -70,7 +70,7 @@ export const join: typeof path.join = function (...args) { return '.' } - return normalize(joined) + return normalize(joined.replace(/\/\/+/g, '/')) } // resolve diff --git a/test/index.spec.ts b/test/index.spec.ts index d1e6048..e3e43e5 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -80,6 +80,8 @@ runTest('format', format, [ ]) runTest('join', join, [ + ['/', '/path', '/path'], + ['/test//', '//path', '/test/path'], ['some/nodejs/deep', '../path', 'some/nodejs/path'], ['./some/local/unix/', '../path', 'some/local/path'], ['./some\\current\\mixed', '..\\path', 'some/current/path'], @@ -168,6 +170,7 @@ runTest('relative', relative, [ runTest('resolve', resolve, [ // POSIX + ['/', '/path', '/path'], ['/foo/bar', './baz', '/foo/bar/baz'], ['/foo/bar', '/tmp/file/', '/tmp/file'], ['wwwroot', 'static_files/png/', '../gif/image.gif', `${process.cwd()}/wwwroot/static_files/gif/image.gif`],