diff --git a/src/utils.ts b/src/utils.ts index fdd160a7..b9039e40 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -42,7 +42,10 @@ export function joinURL (base: string, ...input: string[]): string { let url = base || '' for (const i of input) { - url = withTrailingSlash(url) + withoutLeadingSlash(i) + const part = withoutLeadingSlash(i) + if (part !== '/') { + url = withTrailingSlash(url) + part + } } return url diff --git a/test/join.test.ts b/test/join.test.ts index bb75b118..5fb9313d 100644 --- a/test/join.test.ts +++ b/test/join.test.ts @@ -7,6 +7,7 @@ describe('joinURL', () => { { input: ['/'], out: '/' }, { input: ['/a'], out: '/a' }, { input: ['a', 'b'], out: 'a/b' }, + { input: ['/', '/b'], out: '/b' }, { input: ['a', 'b/', 'c'], out: 'a/b/c' }, { input: ['a', 'b/', '/c'], out: 'a/b/c' } ]