mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-10-27 02:27:18 +00:00
drop anywhere in folder
This commit is contained in:
1 parent
a5c1f6ad33
commit
8fd47d8b18
2 files changed
+21
-8
No files matched your search
@@ -33,6 +33,12 @@ function isSeparator(char: string | undefined) {
|
||||
return char === '/' || char === '\\';
|
||||
}
|
||||
|
||||
/** The folder that holds `path`. */
|
||||
export function parentOf(path: string): string {
|
||||
const index = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'));
|
||||
return index > 0 ? path.slice(0, index) : path;
|
||||
}
|
||||
|
||||
/** Whether `path` is `folder` or something in it. */
|
||||
export function isWithin(path: string, folder: string): boolean {
|
||||
return path === folder || (path.startsWith(folder) && isSeparator(path[folder.length]));
|
||||
|
||||
Reference in new issue
Block a user