A- Add more tests.

- Object Storage support has also been confirmed (and fixed) in CLI.
This commit is contained in:
vorotamoroz
2026-03-12 18:20:55 +09:00
parent 5d80258a77
commit d4aedf59f3
13 changed files with 892 additions and 281 deletions

View File

@@ -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);