Skip to content

Commit b6225ea

Browse files
authored
chore: simplify regexes (#1055)
1 parent 4c45e44 commit b6225ea

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/deps.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ const builtins = new Set([
9898
'zlib',
9999
])
100100

101-
const nameRe =
102-
/^(?<name>(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*)\/?.*$/i
101+
const nameRe = /^(?<name>(@[a-z\d-~][\w-.~]*\/)?[a-z\d-~][\w-.~]*)\/?.*$/i
103102
const versionRe = /^@(?<version>[~^]?(v?[\dx*]+([-.][\d*a-z-]+)*))/i
104103

105104
export function parseDeps(content: Buffer | string): Record<string, string> {

src/util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export function formatCmd(cmd?: string): string {
265265
}
266266

267267
function word() {
268-
if (/[0-9a-z/_.]/i.test(ch)) return word
268+
if (/[\w/.]/i.test(ch)) return word
269269
return root
270270
}
271271

0 commit comments

Comments
 (0)