diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-05 17:37:43 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-05 17:37:43 +1100 |
| commit | d46b36860666583cd9645bfb1fa28d807973c324 (patch) | |
| tree | 97148da2ccf623491f5bdef5e998fb54e4574d52 /src/utils/strings.ts | |
| parent | app: init services after timeout (diff) | |
| download | caelestia-shell-d46b36860666583cd9645bfb1fa28d807973c324.tar.gz caelestia-shell-d46b36860666583cd9645bfb1fa28d807973c324.tar.bz2 caelestia-shell-d46b36860666583cd9645bfb1fa28d807973c324.zip | |
schemes: update for scripts refactor
Diffstat (limited to 'src/utils/strings.ts')
| -rw-r--r-- | src/utils/strings.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/utils/strings.ts b/src/utils/strings.ts index 2fd4c76..c2bf71a 100644 --- a/src/utils/strings.ts +++ b/src/utils/strings.ts @@ -1,3 +1,7 @@ export const ellipsize = (str: string, len: number) => (str.length > len ? `${str.slice(0, len - 1)}…` : str); -export const basename = (path: string) => path.slice(path.lastIndexOf("/") + 1, path.lastIndexOf(".")); +export const basename = (path: string) => { + const lastSlash = path.lastIndexOf("/"); + const lastDot = path.lastIndexOf("."); + return path.slice(lastSlash + 1, lastDot > lastSlash ? lastDot : undefined); +}; |