mirror of
https://github.com/actions/setup-java.git
synced 2026-11-14 21:20:34 +08:00
Architecture validation for JDK file installs (#1324)
* Enhance architecture validation and error handling * Improve architecture normalization and validation for custom tokens * Refactor architecture validation to consolidate error handling for invalid tokens
This commit is contained in:
Vendored
+11
-2
@@ -31545,6 +31545,8 @@ const CANONICAL_ARCHITECTURES = [
|
||||
'riscv64',
|
||||
's390x'
|
||||
];
|
||||
// Used in environment-variable names and tool-cache paths.
|
||||
const ARCHITECTURE_TOKEN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
||||
const PLATFORM_ALIASES = {
|
||||
darwin: 'macos',
|
||||
linux: 'linux',
|
||||
@@ -31554,10 +31556,17 @@ const PLATFORM_ALIASES = {
|
||||
function normalizeArchitecture(architecture) {
|
||||
const trimmedArchitecture = architecture.trim();
|
||||
const normalizedArchitecture = trimmedArchitecture.toLowerCase();
|
||||
return (ARCHITECTURE_ALIASES[normalizedArchitecture] ??
|
||||
const alias = Object.prototype.hasOwnProperty.call(ARCHITECTURE_ALIASES, normalizedArchitecture)
|
||||
? ARCHITECTURE_ALIASES[normalizedArchitecture]
|
||||
: undefined;
|
||||
const result = alias ??
|
||||
(CANONICAL_ARCHITECTURES.includes(normalizedArchitecture)
|
||||
? normalizedArchitecture
|
||||
: trimmedArchitecture));
|
||||
: trimmedArchitecture);
|
||||
if (!ARCHITECTURE_TOKEN.test(result)) {
|
||||
throw new Error(`Unsupported architecture value: ${JSON.stringify(architecture)}`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function normalizePlatform(platform) {
|
||||
return PLATFORM_ALIASES[platform];
|
||||
|
||||
Reference in New Issue
Block a user