nosignal-shell/src/utils/strings.ts
2 * r + 2 * t 65d0511408 bar: fix workspaces visual glitch
Also use gtk truncate for active window and media playing
For some reason, odd numbers of workspaces need the adjustment, but even don't
2025-04-02 23:38:04 +11:00

11 lines
545 B
TypeScript

export const basename = (path: string, stripExt = true) => {
const lastSlash = path.lastIndexOf("/");
const lastDot = path.lastIndexOf(".");
return path.slice(lastSlash + 1, stripExt && lastDot > lastSlash ? lastDot : undefined);
};
export const pathToFileName = (path: string, ext?: string) => {
const start = /[a-z]+:\/\//.test(path) ? 0 : path.indexOf("/") + 1;
const dir = path.slice(start, path.lastIndexOf("/")).replaceAll("/", "-");
return `${dir}-${basename(path, ext !== undefined)}${ext ? `.${ext}` : ""}`;
};