From ce2712bb0897a9260a19986af59e6829363974f9 Mon Sep 17 00:00:00 2001 From: futsuuu Date: Mon, 25 Sep 2023 12:45:12 +0900 Subject: [PATCH] fix(semver): Add a necessary grouping --- semver/parse.ts | 2 +- semver/parse_test.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/semver/parse.ts b/semver/parse.ts index 146c805b70ae..32c1670584ce 100644 --- a/semver/parse.ts +++ b/semver/parse.ts @@ -56,7 +56,7 @@ export function parse(version: string | SemVer): SemVer { } // number-ify any prerelease numeric ids - const numericIdentifier = new RegExp(`^${src[NUMERICIDENTIFIER]}$`); + const numericIdentifier = new RegExp(`^(${src[NUMERICIDENTIFIER]})$`); const prerelease = (m[4] ?? "") .split(".") .filter((id) => id) diff --git a/semver/parse_test.ts b/semver/parse_test.ts index 2419cfad2c6c..f48c8f6633f4 100644 --- a/semver/parse_test.ts +++ b/semver/parse_test.ts @@ -73,6 +73,8 @@ Deno.test("prerelease", async (t) => { ["1.0.0-beta.2", ["beta", 2]], ["v0.5.4-pre", ["pre"]], ["1.2.2-alpha.1", ["alpha", 1]], + ["1.2.0-1b3-4", ["1b3-4"]], + ["1.2.0-3.6-pre2", [3, "6-pre2"]], ["2.0.0", []], ];