From 80ddf5e995066f9ab6af423aa06f06de9e2d986f Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Sun, 5 Jan 2025 22:40:51 +0300 Subject: [PATCH] chore: simplify regexes --- src/deps.ts | 3 +-- src/util.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/deps.ts b/src/deps.ts index 5d02447a20..b8601af35c 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -98,8 +98,7 @@ const builtins = new Set([ 'zlib', ]) -const nameRe = - /^(?(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*)\/?.*$/i +const nameRe = /^(?(@[a-z\d-~][\w-.~]*\/)?[a-z\d-~][\w-.~]*)\/?.*$/i const versionRe = /^@(?[~^]?(v?[\dx*]+([-.][\d*a-z-]+)*))/i export function parseDeps(content: Buffer | string): Record { diff --git a/src/util.ts b/src/util.ts index 2f63edffb5..3d8ecdf24e 100644 --- a/src/util.ts +++ b/src/util.ts @@ -265,7 +265,7 @@ export function formatCmd(cmd?: string): string { } function word() { - if (/[0-9a-z/_.]/i.test(ch)) return word + if (/[\w/.]/i.test(ch)) return word return root }