mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
14 lines
270 B
TypeScript
14 lines
270 B
TypeScript
export function dirname(path: string) {
|
|
const parts = path.split('/')
|
|
if (parts.length <= 2) {
|
|
return '/'
|
|
}
|
|
parts.pop()
|
|
return parts.join('/')
|
|
}
|
|
|
|
export function basename(path: string): string {
|
|
const parts = path.split('/')
|
|
return parts.pop() ?? ''
|
|
}
|