Skip to content

Commit

Permalink
fix(joinURL): allow falsy base (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Mar 9, 2021
1 parent 228da37 commit 73220dd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ export function joinURL (base: string, ...input: string[]): string {
let url = base || ''

for (const i of input.filter(isNonEmptyURL)) {
const part = withoutLeadingSlash(i)
url = withTrailingSlash(url) + part
url = url ? withTrailingSlash(url) + withoutLeadingSlash(i) : i
}

return url
Expand Down
1 change: 1 addition & 0 deletions test/join.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ describe('joinURL', () => {
const tests = [
{ input: [], out: '' },
{ input: ['/'], out: '/' },
{ input: [null, './'], out: './' },
{ input: ['/a'], out: '/a' },
{ input: ['a', 'b'], out: 'a/b' },
{ input: ['/', '/b'], out: '/b' },
Expand Down

0 comments on commit 73220dd

Please sign in to comment.