mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-05-04 14:51:52 +00:00
A- Add more tests.
- Object Storage support has also been confirmed (and fixed) in CLI.
This commit is contained in:
@@ -8,7 +8,13 @@ export function toArrayBuffer(data: Buffer): ArrayBuffer {
|
||||
export function toVaultRelativePath(inputPath: string, vaultPath: string): string {
|
||||
const stripped = inputPath.replace(/^[/\\]+/, "");
|
||||
if (!path.isAbsolute(inputPath)) {
|
||||
return stripped.replace(/\\/g, "/");
|
||||
const normalized = stripped.replace(/\\/g, "/");
|
||||
const resolved = path.resolve(vaultPath, normalized);
|
||||
const rel = path.relative(vaultPath, resolved);
|
||||
if (rel.startsWith("..") || path.isAbsolute(rel)) {
|
||||
throw new Error(`Path ${inputPath} is outside of the local database directory`);
|
||||
}
|
||||
return rel.replace(/\\/g, "/");
|
||||
}
|
||||
const resolved = path.resolve(inputPath);
|
||||
const rel = path.relative(vaultPath, resolved);
|
||||
|
||||
Reference in New Issue
Block a user