Download apps/readest-app/src/utils/path.ts from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/apps/readest-app/src/utils/path.ts
- Command line
-
hf download hf://datasets/echodict/readest/apps/readest-app/src/utils/path.ts
-
curl -L -o path.ts https://huggingface.co/datasets/echodict/readest/resolve/main/apps/readest-app/src/utils/path.ts
1.03 kB
| import { join } from '@tauri-apps/api/path'; | |
| import { isContentURI, isFileURI, isValidURL } from './misc'; | |
| export const getFilename = (fileOrUri: string) => { | |
| if (isValidURL(fileOrUri) || isContentURI(fileOrUri) || isFileURI(fileOrUri)) { | |
| fileOrUri = decodeURI(fileOrUri); | |
| } | |
| const normalizedPath = fileOrUri.replace(/\\/g, '/'); | |
| const parts = normalizedPath.split('/'); | |
| const lastPart = parts.pop()!; | |
| return lastPart.split('?')[0]!; | |
| }; | |
| export const getBaseFilename = (filename: string) => { | |
| const normalizedPath = filename.replace(/\\/g, '/'); | |
| const name = normalizedPath.split('/').pop() || ''; | |
| const parts = name.split('.'); | |
| if (parts.length <= 1) { | |
| return name; | |
| } | |
| return parts.slice(0, -1).join('.'); | |
| }; | |
| export const getDirPath = (filePath: string) => { | |
| const normalizedPath = filePath.replace(/\\/g, '/'); | |
| const parts = normalizedPath.split('/'); | |
| parts.pop(); | |
| return parts.join('/'); | |
| }; | |
| export const joinPaths = async (...paths: string[]) => { | |
| return await join(...paths); | |
| }; | |