fix(coding-agent): Clean up Path Handling (#4873)
This commit is contained in:
@@ -16,6 +16,11 @@ describe("path-utils", () => {
|
||||
expect(result).not.toContain("~/");
|
||||
});
|
||||
|
||||
it("should keep tilde-prefixed filenames literal", () => {
|
||||
expect(expandPath("~draft.md")).toBe("~draft.md");
|
||||
expect(expandPath("@~draft.md")).toBe("~draft.md");
|
||||
});
|
||||
|
||||
it("should normalize Unicode spaces", () => {
|
||||
// Non-breaking space (U+00A0) should become regular space
|
||||
const withNBSP = "file\u00A0name.txt";
|
||||
@@ -26,14 +31,21 @@ describe("path-utils", () => {
|
||||
|
||||
describe("resolveToCwd", () => {
|
||||
it("should resolve absolute paths as-is", () => {
|
||||
const result = resolveToCwd("/absolute/path/file.txt", "/some/cwd");
|
||||
expect(result).toBe("/absolute/path/file.txt");
|
||||
const absolutePath = resolve(tmpdir(), "absolute", "path", "file.txt");
|
||||
const result = resolveToCwd(absolutePath, resolve(tmpdir(), "some", "cwd"));
|
||||
expect(result).toBe(absolutePath);
|
||||
});
|
||||
|
||||
it("should resolve relative paths against cwd", () => {
|
||||
const result = resolveToCwd("relative/file.txt", "/some/cwd");
|
||||
expect(result).toBe(resolve("/some/cwd", "relative/file.txt"));
|
||||
});
|
||||
|
||||
it("should resolve tilde-prefixed filenames against cwd", () => {
|
||||
const cwd = join(tmpdir(), "pi-path-utils-cwd");
|
||||
expect(resolveToCwd("~draft.md", cwd)).toBe(resolve(cwd, "~draft.md"));
|
||||
expect(resolveToCwd("@~draft.md", cwd)).toBe(resolve(cwd, "~draft.md"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveReadPath", () => {
|
||||
|
||||
Reference in New Issue
Block a user