Skip to content

Commit

Permalink
additional error handling for version coercion
Browse files Browse the repository at this point in the history
  • Loading branch information
IDCs committed Aug 21, 2024
1 parent 112ee0c commit 0045996
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/extensions/mod_management/util/testModReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function safeCoerce(input: string): string {

export function coerceToSemver(version: string): string {
if (!version) {
return version;
return undefined;
}
const match = version.match(/^(\d+)\.(\d+)\.(\d+)(.*)$/);
if (match) {
Expand All @@ -85,7 +85,10 @@ export function coerceToSemver(version: string): string {
return `${major}.${minor}.${patch}`;
}
} else {
return semver.coerce(version).version ?? version;
if (coerceableRE.test(version)) {
return semver.coerce(version).version ?? version;
}
return version;
}
}

Expand Down

0 comments on commit 0045996

Please sign in to comment.