Skip to content

Commit

Permalink
chore: simplify regexes (#1055)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub authored Jan 5, 2025
1 parent 4c45e44 commit b6225ea
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ const builtins = new Set([
'zlib',
])

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

export function parseDeps(content: Buffer | string): Record<string, string> {
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit b6225ea

Please sign in to comment.