fix(observer): hook-resolver — Windows backslash path support

Code-review followup. TOOL_SCRIPT_RE didn't include \ in delimiter
char class — Windows-native commands like `node tools\foo.mjs` fell
through to inline:<sha> fallback. Added \ to char class + inner
[\/\] alternation, normalize match to forward-slash.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Дмитрий
2026-05-23 13:19:53 +03:00
parent 4665c537e8
commit 7fdf0ba971
3 changed files with 13 additions and 5 deletions
+2 -2
View File
@@ -13,7 +13,7 @@
import { createHash } from 'node:crypto';
const TOOL_SCRIPT_RE = /(?:^|[\s"'/])(tools\/[\w-]+\.(?:mjs|py|sh))/;
const TOOL_SCRIPT_RE = /(?:^|[\s"'/\\])(tools[\/\\][\w-]+\.(?:mjs|py|sh))/;
const NPX_RE = /(?:^|[\s"'])npx\s+(?:-y\s+)?([\w@/.-]+)/;
/**
@@ -33,7 +33,7 @@ function normalizeCommand(s) {
export function extractScriptName(command) {
const cmd = String(command || '');
const toolMatch = cmd.match(TOOL_SCRIPT_RE);
if (toolMatch) return toolMatch[1];
if (toolMatch) return toolMatch[1].replace(/\\/g, '/');
const npxMatch = cmd.match(NPX_RE);
if (npxMatch) return npxMatch[1];
const sha = createHash('sha256').update(normalizeCommand(cmd)).digest('hex').slice(0, 16);