Skip to content

Commit 1f98f0f

Browse files
committedDec 14, 2022
try to naively deal with weird input formats
1 parent e7b1548 commit 1f98f0f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed
 

‎action/src/main.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,20 @@ class Inputs {
8585
throw TypeError(`target: "${target}" is not one of "desktop" | "android" | "ios"`);
8686
}
8787

88-
this.version = core.getInput("version");
88+
// An attempt to sanitize non-straightforward version number input
89+
let version = core.getInput("version");
90+
const dots = version.match(/\./g).length;
91+
const desiredDotCount = 2;
92+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
93+
if (dots < desiredDotCount && version.slice(-1) !== "*") {
94+
version = version.concat(".*");
95+
} else if (dots > desiredDotCount) {
96+
throw TypeError(
97+
`version: "${version}$ is a malformed semantic version: must be formatted like "6.2.0" or "6.*"`
98+
);
99+
}
100+
101+
this.version = version;
89102

90103
this.arch = core.getInput("arch");
91104
// Set arch automatically if omitted

0 commit comments

Comments
 (0)
Please sign in to comment.