Skip to content

Commit

Permalink
fix: replace double-slashes in join calls (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jun 27, 2022
1 parent e15d5da commit fd57079
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/path.ts
Expand Up @@ -70,7 +70,7 @@ export const join: typeof path.join = function (...args) {
return '.'
}

return normalize(joined)
return normalize(joined.replace(/\/\/+/g, '/'))
}

// resolve
Expand Down
3 changes: 3 additions & 0 deletions test/index.spec.ts
Expand Up @@ -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'],
Expand Down Expand Up @@ -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`],
Expand Down

0 comments on commit fd57079

Please sign in to comment.