diff --git a/.claude/worktrees/agent-ad3369ec b/.claude/worktrees/agent-ad3369ec new file mode 160000 index 0000000..5f35206 --- /dev/null +++ b/.claude/worktrees/agent-ad3369ec @@ -0,0 +1 @@ +Subproject commit 5f3520658d949372276bf27be0aa8b2ff0d9193c diff --git a/src/core/packs.ts b/src/core/packs.ts index 47bfc57..5dd65b1 100644 --- a/src/core/packs.ts +++ b/src/core/packs.ts @@ -691,8 +691,9 @@ export function createPack(db: Database.Database, options: CreatePackOptions): K /** Simple glob-style pattern matching (supports * and ** wildcards). */ function matchesExcludePattern(relativePath: string, pattern: string): boolean { // Escape regex special chars except * and ** + // prettier-ignore const escaped = pattern - .replace(/[.+^${}()|[\]\\]/g, "\\$&") + .replaceAll(/[.+^${}()|[\]\\]/g, String.raw`\$&`) .replaceAll("**", "\0") .replaceAll("*", "[^/]*") .replaceAll("\0", ".*"); diff --git a/src/core/parsers/csv.ts b/src/core/parsers/csv.ts index 99012d1..8d13271 100644 --- a/src/core/parsers/csv.ts +++ b/src/core/parsers/csv.ts @@ -18,8 +18,9 @@ export class CsvParser implements DocumentParser { const colCount = header.length; const rows = records.slice(1); + // prettier-ignore const escapeCell = (cell: string): string => - cell.replaceAll("\\", "\\\\").replaceAll("|", "\\|").replaceAll("\n", " "); + cell.replaceAll("\\", String.raw`\\`).replaceAll("|", String.raw`\|`).replaceAll("\n", " "); const lines: string[] = []; lines.push( diff --git a/src/core/search.ts b/src/core/search.ts index 76d8519..c0570fd 100644 --- a/src/core/search.ts +++ b/src/core/search.ts @@ -39,11 +39,12 @@ function isVectorTableError(err: unknown): boolean { /** Escape LIKE special characters so user input is treated literally. */ export function escapeLikePattern(input: string): string { + // prettier-ignore return input - .replace(/\\/g, "\\\\") - .replace(/%/g, "\\%") - .replace(/_/g, "\\_") - .replace(/\[/g, "\\["); + .replaceAll("\\", String.raw`\\`) + .replaceAll("%", String.raw`\%`) + .replaceAll("_", String.raw`\_`) + .replaceAll("[", String.raw`\[`); } export interface SearchOptions { diff --git a/tests/unit/parsers.test.ts b/tests/unit/parsers.test.ts index a49f29a..c6495c4 100644 --- a/tests/unit/parsers.test.ts +++ b/tests/unit/parsers.test.ts @@ -174,7 +174,8 @@ describe("CsvParser", () => { it("escapes pipe characters in cell values", async () => { const input = "col1,col2\nfoo|bar,baz"; const result = await parser.parse(Buffer.from(input)); - expect(result).toContain("foo\\|bar"); + // prettier-ignore + expect(result).toContain(String.raw`foo\|bar`); }); it("replaces newlines in cell values", async () => { diff --git a/tests/unit/registry/publish.test.ts b/tests/unit/registry/publish.test.ts index 69bad36..aeff724 100644 --- a/tests/unit/registry/publish.test.ts +++ b/tests/unit/registry/publish.test.ts @@ -184,7 +184,8 @@ describe("registry publish", () => { addTestRegistry(makeEntry(regName, bareUrl)); const packFile = join(tempDir, "backslash.json"); - writeFileSync(packFile, JSON.stringify(makePackJson("foo\\bar")), "utf-8"); + // prettier-ignore + writeFileSync(packFile, JSON.stringify(makePackJson(String.raw`foo\bar`)), "utf-8"); await expect(publishPack({ registryName: regName, packFilePath: packFile })).rejects.toThrow( /path separators/i,