Files
openwork/packages/app/scripts/local-file-path.mjs
xj 5a58f62a26 fix(session): improve editor/artifact file open reliability (#704)
* fix(session): improve local file-open fallback and diagnostics

* fix(session): normalize file URI local path resolution

* test(session): cover file URI normalization edge cases

* test(app): include local file-path regression in e2e flow

* fix(ci): run app e2e script and normalize file:/ URIs

* test(app): run local file-path regression without bun

---------

Co-authored-by: xj <gh-xj@users.noreply.github.com>
2026-03-02 16:04:31 -08:00

22 lines
919 B
JavaScript

import assert from "node:assert/strict";
import { normalizeLocalFilePath } from "../src/app/lib/local-file-path.impl.js";
const equals = (input, expected) => {
assert.equal(normalizeLocalFilePath(input), expected, `normalizeLocalFilePath(${input})`);
};
equals(" notes/todo.md ", "notes/todo.md");
equals("file:///tmp/notes.md", "/tmp/notes.md");
equals("file:/tmp/notes.md", "/tmp/notes.md");
equals("file:///C:/Users/xj/note.md", "C:/Users/xj/note.md");
equals("file://server/share/note.md", "//server/share/note.md");
equals("file://localhost/tmp/notes.md", "/tmp/notes.md");
equals("FILE:///tmp/notes.md", "/tmp/notes.md");
assert.doesNotThrow(() => normalizeLocalFilePath("file:///tmp/100%/note.md"));
equals("file:///tmp/100%/note.md", "/tmp/100%/note.md");
assert.doesNotThrow(() => normalizeLocalFilePath("file://%zz"));
equals("file://%zz", "%zz");
console.log(JSON.stringify({ ok: true, checks: 11 }));