mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-05-17 00:16:06 +03:00
19 lines
671 B
TypeScript
19 lines
671 B
TypeScript
|
|
import type { FilePath } from "../../../lib/src/common/types";
|
||
|
|
import type { IPathAdapter } from "../../../lib/src/serviceModules/adapters";
|
||
|
|
import type { FSAPIFile } from "./FSAPITypes";
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Path adapter implementation for FileSystem API
|
||
|
|
*/
|
||
|
|
export class FSAPIPathAdapter implements IPathAdapter<FSAPIFile> {
|
||
|
|
getPath(file: string | FSAPIFile): FilePath {
|
||
|
|
return (typeof file === "string" ? file : file.path) as FilePath;
|
||
|
|
}
|
||
|
|
|
||
|
|
normalisePath(p: string): string {
|
||
|
|
// Normalize path separators to forward slashes (like Obsidian)
|
||
|
|
// Remove leading/trailing slashes
|
||
|
|
return p.replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
|
||
|
|
}
|
||
|
|
}
|