summaryrefslogtreecommitdiffhomepage
path: root/packages/util/src/path.ts
diff options
context:
space:
mode:
authorDax <[email protected]>2025-11-21 20:41:27 -0500
committerGitHub <[email protected]>2025-11-21 20:41:27 -0500
commit49408c00e964093c654ee270d545c0e29857e61f (patch)
tree600b2a94cd082c0af221fd84fd5346cfe8f9ace4 /packages/util/src/path.ts
parent76192fbcedff945b5d529a5d733deb2488ee9c8a (diff)
downloadopencode-49408c00e964093c654ee270d545c0e29857e61f.tar.gz
opencode-49408c00e964093c654ee270d545c0e29857e61f.zip
enterprise (#4617)
Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Adam <[email protected]>
Diffstat (limited to 'packages/util/src/path.ts')
-rw-r--r--packages/util/src/path.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/util/src/path.ts b/packages/util/src/path.ts
new file mode 100644
index 000000000..fbb84878d
--- /dev/null
+++ b/packages/util/src/path.ts
@@ -0,0 +1,16 @@
+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]
+}