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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user