Skip to content

Commit 51bde41

Browse files
aegilopsCopilot
andauthored
Update src/sbomCollector.ts
Co-authored-by: Copilot <[email protected]>
1 parent bd656c6 commit 51bde41

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/sbomCollector.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ export class SbomCollector {
4848
if (!options.loadFromDir && !options.enterprise && !options.org && !options.repo) {
4949
throw new Error("One of enterprise/org/repo or loadFromDir must be specified");
5050
}
51+
// Validate repo format if provided
52+
if (options.repo) {
53+
if (typeof options.repo !== "string" || !options.repo.includes("/")) {
54+
throw new Error('If specifying "repo", it must be in the format "org/repo".');
55+
}
56+
const [orgPart, repoPart] = options.repo.split("/");
57+
if (!orgPart || !repoPart) {
58+
throw new Error('If specifying "repo", it must be in the format "org/repo" with both parts non-empty.');
59+
}
60+
}
5161
// Spread user options first then apply defaults via nullish coalescing so that
5262
// passing undefined does not erase defaults
5363
const o = { ...options };

0 commit comments

Comments
 (0)