Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ export function extname(path: string): string {
return ''
}

/**
* Joins multiple path segments into a single path.
*
* @param args - The path segments to join
* @deprecated use `join()` instead
*/
export function joinPaths(...args: string[]): string {
return join(...args)
}

/**
* Joins multiple path segments into a single path.
*
Expand Down
52 changes: 52 additions & 0 deletions test/join.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import { describe, expect, it } from 'vitest'
import { join } from '../lib/index.ts'

describe('join', () => {
it('returns empty string with no or empty arguments', function() {
expect(join()).toEqual('')
expect(join('')).toEqual('')
expect(join('', '')).toEqual('')
})
it('returns joined path sections', function() {
expect(join('abc')).toEqual('abc')
expect(join('abc', 'def')).toEqual('abc/def')
expect(join('abc', 'def', 'ghi')).toEqual('abc/def/ghi')
})
it('keeps leading slashes', function() {
expect(join('/abc')).toEqual('/abc')
expect(join('/abc', '')).toEqual('/abc')
expect(join('', '/abc')).toEqual('/abc')
expect(join('/abc', 'def')).toEqual('/abc/def')
expect(join('/abc', 'def', 'ghi')).toEqual('/abc/def/ghi')
})
it('keeps trailing slashes', function() {
expect(join('', 'abc/')).toEqual('abc/')
expect(join('abc/')).toEqual('abc/')
expect(join('abc/', '')).toEqual('abc/')
expect(join('abc', 'def/')).toEqual('abc/def/')
expect(join('abc', 'def', 'ghi/')).toEqual('abc/def/ghi/')
})
it('splits paths in specified strings and discards extra slashes', function() {
expect(join('//abc//')).toEqual('/abc/')
expect(join('//abc//def//')).toEqual('/abc/def/')
expect(join('//abc//', '//def//')).toEqual('/abc/def/')
expect(join('//abc//', '//def//', '//ghi//')).toEqual('/abc/def/ghi/')
expect(join('//abc//def//', '//ghi//jkl/mno/', '//pqr//')).toEqual('/abc/def/ghi/jkl/mno/pqr/')
expect(join('/abc', '/def')).toEqual('/abc/def')
expect(join('/abc/', '/def')).toEqual('/abc/def')
expect(join('/abc/', 'def')).toEqual('/abc/def')
})
it('discards empty sections', function() {
expect(join('abc', '', 'def')).toEqual('abc/def')
})
it('returns root if only slashes', function() {
expect(join('//')).toEqual('/')
expect(join('/', '/')).toEqual('/')
expect(join('/', '//', '/')).toEqual('/')
})
})
52 changes: 0 additions & 52 deletions test/joinPaths.test.ts

This file was deleted.