From cbfb614d4150416eff6cfa5d8d7363f5e4e86c3b Mon Sep 17 00:00:00 2001 From: LunarLaurus Date: Wed, 13 May 2026 08:01:19 +0100 Subject: [PATCH] fix(schema): escape path.sep before use in RegExp character class on Windows On Windows, path.sep is '\'. When interpolated directly into a RegExp character class as [^\], the backslash escapes the closing bracket, leaving the class unterminated and throwing a SyntaxError at startup. Escape the separator before building the RegExp so it works on both platforms: path.sep.replace(/\/g, '\\') produces '\' on Windows (matching a literal backslash in the pattern) and is a no-op on POSIX. --- scripts/schema.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/schema.js b/scripts/schema.js index 3603665..b99fa8a 100644 --- a/scripts/schema.js +++ b/scripts/schema.js @@ -182,7 +182,9 @@ function inferExpectedSchema(filepath, { brainRoot } = {}) { } // Projects//.md - const projMatch = rel.match(new RegExp(`^Projects\\${path.sep}([^${path.sep}]+)\\${path.sep}(.+)$`)); + // path.sep on Windows is '\', which is invalid unescaped inside a RegExp character class. + const sep = path.sep.replace(/\\/g, '\\\\'); + const projMatch = rel.match(new RegExp(`^Projects${sep}([^${sep}]+)${sep}(.+)$`)); if (projMatch) { const projName = projMatch[1]; const subPath = projMatch[2];