mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com>
16 lines
443 B
TypeScript
16 lines
443 B
TypeScript
export function getFilename(path: string) {
|
|
if (!path) return ""
|
|
const trimmed = path.replace(/[\/]+$/, "")
|
|
const parts = trimmed.split("/")
|
|
return parts[parts.length - 1] ?? ""
|
|
}
|
|
|
|
export function getDirectory(path: string) {
|
|
const parts = path.split("/")
|
|
return parts.slice(0, parts.length - 1).join("/") + "/"
|
|
}
|
|
|
|
export function getFileExtension(path: string) {
|
|
const parts = path.split(".")
|
|
return parts[parts.length - 1]
|
|
}
|