diff --git a/lib/helpers/regexes.js b/lib/helpers/regexes.js index d4bc2fa..0d33e5e 100644 --- a/lib/helpers/regexes.js +++ b/lib/helpers/regexes.js @@ -1,5 +1,5 @@ -// source: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string -export const semVerRegexLine = new RegExp( +/** source: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string */ +const semVerRegexLine = new RegExp( /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/, ); const semVerRegex = new RegExp(semVerRegexLine.source.replace(/[\^$]/g, "")); diff --git a/lib/helpers/regexes.spec.js b/lib/helpers/regexes.spec.js index 3456da1..aba2d8f 100644 --- a/lib/helpers/regexes.spec.js +++ b/lib/helpers/regexes.spec.js @@ -2,27 +2,7 @@ import { invalidSemVers, validSemVers, } from "../../tests/fixtures/regexes.fixture"; -import { semVerRegexLine, versionRegex } from "./regexes"; - -describe("semVerRegexLine", () => { - it("should match valid values", () => { - // eslint-disable-next-line jest/prefer-expect-assertions - expect.assertions(validSemVers.length); - - for (let semVer of validSemVers) { - expect(semVer).toMatch(semVerRegexLine); - } - }); - - it("should not match invalid values", () => { - // eslint-disable-next-line jest/prefer-expect-assertions - expect.assertions(invalidSemVers.length); - - for (let semVer of invalidSemVers) { - expect(semVer).not.toMatch(semVerRegexLine); - } - }); -}); +import { versionRegex } from "./regexes"; describe("versionRegex", () => { it("should match valid values", () => {