mirror of
https://github.com/github/codeql-action.git
synced 2026-11-10 14:56:01 +00:00
Make input-validation assertions more granular
This commit is contained in:
@@ -64,14 +64,14 @@ describe("parseOptions", async () => {
|
||||
await it("rejects an empty --marker", () => {
|
||||
assert.throws(
|
||||
() => parseOptions(withFlag("--marker", "")),
|
||||
/Missing required flag --marker/,
|
||||
/The value for --marker cannot be empty/,
|
||||
);
|
||||
});
|
||||
|
||||
await it("rejects a whitespace-only --marker", () => {
|
||||
assert.throws(
|
||||
() => parseOptions(withFlag("--marker", " \t\n")),
|
||||
/Missing required flag --marker/,
|
||||
/The value for --marker cannot be empty/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,12 +46,16 @@ export function parseOptions(argv?: string[]): Options {
|
||||
strict: true,
|
||||
});
|
||||
|
||||
assert(values.marker?.trim(), "Missing required flag --marker.");
|
||||
assert(values.marker !== undefined, "Missing required flag --marker.");
|
||||
assert(
|
||||
values.marker.trim() !== "",
|
||||
"The value for --marker cannot be empty.",
|
||||
);
|
||||
const [owner, repo] = values.repository!.split("/");
|
||||
|
||||
return {
|
||||
body: values.body!,
|
||||
marker: values.marker!,
|
||||
marker: values.marker,
|
||||
issueId: Number(values["issue-id"]),
|
||||
repository: { owner, repo },
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user