Make URL parsing more robust
This commit is contained in:
parent
2841489ddf
commit
c4dc1b0438
9 changed files with 179 additions and 47 deletions
|
|
@ -122,3 +122,63 @@ test("getExtraOptionsEnvParam() fails on invalid JSON", (t) => {
|
|||
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
});
|
||||
|
||||
test("parseGithubUrl", (t) => {
|
||||
t.deepEqual(util.parseGithubUrl("github.com"), "https://github.com/");
|
||||
t.deepEqual(util.parseGithubUrl("https://github.com"), "https://github.com/");
|
||||
t.deepEqual(
|
||||
util.parseGithubUrl("https://api.github.com"),
|
||||
"https://github.com/"
|
||||
);
|
||||
t.deepEqual(
|
||||
util.parseGithubUrl("https://github.com/foo/bar"),
|
||||
"https://github.com/"
|
||||
);
|
||||
|
||||
t.deepEqual(
|
||||
util.parseGithubUrl("github.example.com"),
|
||||
"https://github.example.com/"
|
||||
);
|
||||
t.deepEqual(
|
||||
util.parseGithubUrl("https://github.example.com"),
|
||||
"https://github.example.com/"
|
||||
);
|
||||
t.deepEqual(
|
||||
util.parseGithubUrl("https://api.github.example.com"),
|
||||
"https://github.example.com/"
|
||||
);
|
||||
t.deepEqual(
|
||||
util.parseGithubUrl("https://github.example.com/api/v3"),
|
||||
"https://github.example.com/"
|
||||
);
|
||||
t.deepEqual(
|
||||
util.parseGithubUrl("https://github.example.com:1234"),
|
||||
"https://github.example.com:1234/"
|
||||
);
|
||||
t.deepEqual(
|
||||
util.parseGithubUrl("https://api.github.example.com:1234"),
|
||||
"https://github.example.com:1234/"
|
||||
);
|
||||
t.deepEqual(
|
||||
util.parseGithubUrl("https://github.example.com:1234/api/v3"),
|
||||
"https://github.example.com:1234/"
|
||||
);
|
||||
t.deepEqual(
|
||||
util.parseGithubUrl("https://github.example.com/base/path"),
|
||||
"https://github.example.com/base/path/"
|
||||
);
|
||||
t.deepEqual(
|
||||
util.parseGithubUrl("https://github.example.com/base/path/api/v3"),
|
||||
"https://github.example.com/base/path/"
|
||||
);
|
||||
|
||||
t.throws(() => util.parseGithubUrl(""), {
|
||||
message: '"" is not a valid URL',
|
||||
});
|
||||
t.throws(() => util.parseGithubUrl("ssh://github.com"), {
|
||||
message: '"ssh://github.com" is not a http or https URL',
|
||||
});
|
||||
t.throws(() => util.parseGithubUrl("http:///::::433"), {
|
||||
message: '"http:///::::433" is not a valid URL',
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue