mirror of
https://github.com/actions/setup-java.git
synced 2026-08-02 16:32:57 +00:00
Reject invalid boolean input values (#1160)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c6daa6b5-31f5-46b2-a994-b8320b50a50d
This commit is contained in:
+15
-2
@@ -20,8 +20,21 @@ export function getTempDir() {
|
||||
}
|
||||
|
||||
export function getBooleanInput(inputName: string, defaultValue = false) {
|
||||
return (
|
||||
(core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'
|
||||
const inputValue = core.getInput(inputName);
|
||||
const normalizedValue = inputValue.trim().toLowerCase();
|
||||
|
||||
if (!normalizedValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (normalizedValue === 'true') {
|
||||
return true;
|
||||
}
|
||||
if (normalizedValue === 'false') {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Invalid value '${inputValue}' for boolean input '${inputName}'. Expected 'true' or 'false'.`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user