#74 - Integration with Bookmarks core plugin and support for indirect drag & drop arrangement
- update of treatment of whitespace in parent path extraction: spaces allowed as leading/trailing in path elements - unit tests
This commit is contained in:
parent
daf657721c
commit
cd933cb4f0
|
@ -9,14 +9,14 @@ describe('lastPathComponent and extractParentFolderPath', () => {
|
|||
['a/subfolder', 'a', 'subfolder'],
|
||||
['parent/child', 'parent', 'child'],
|
||||
['','',''],
|
||||
[' ','',''],
|
||||
[' ','',' '],
|
||||
['/strange', '', 'strange'],
|
||||
['a/b/c/', 'a/b/c', ''],
|
||||
['d d d/e e e/f f f/ggg ggg', 'd d d/e e e/f f f', 'ggg ggg'],
|
||||
['/','',''],
|
||||
[' / ','',''],
|
||||
[' /','',''],
|
||||
['/ ','','']
|
||||
[' / ',' ',' '],
|
||||
[' /',' ',''],
|
||||
['/ ','',' ']
|
||||
])('should from %s extract %s and %s', (path: string, parentPath: string, lastComponent: string) => {
|
||||
const extractedParentPath: string = extractParentFolderPath(path)
|
||||
const extractedLastComponent: string = lastPathComponent(path)
|
||||
|
|
|
@ -9,10 +9,10 @@ export function last<T>(o: Array<T>): T | undefined {
|
|||
|
||||
export function lastPathComponent(path: string): string {
|
||||
const lastPathSeparatorIdx = (path ?? '').lastIndexOf('/')
|
||||
return lastPathSeparatorIdx >= 0 ? path.substring(lastPathSeparatorIdx + 1).trim() : path.trim()
|
||||
return lastPathSeparatorIdx >= 0 ? path.substring(lastPathSeparatorIdx + 1) : path
|
||||
}
|
||||
|
||||
export function extractParentFolderPath(path: string): string {
|
||||
const lastPathSeparatorIdx = (path ?? '').lastIndexOf('/')
|
||||
return lastPathSeparatorIdx > 0 ? path.substring(0, lastPathSeparatorIdx).trim() : ''
|
||||
return lastPathSeparatorIdx > 0 ? path.substring(0, lastPathSeparatorIdx) : ''
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue