Skip to content

Commit ffc173a

Browse files
Potential fix for code scanning alert no. 8: Incomplete URL substring sanitization (#25)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 6222fb6 commit ffc173a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

source/pages/oss-licenses/oss-licenses.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,17 @@ Page({
4040
version: this.data.licensesBuild[index].version,
4141
licenseBody: this.data.licensesBuild[index].licenseText,
4242
repoLink: this.data.licensesBuild[index].repository,
43-
repoType: this.data.licensesBuild[index].repository.toLowerCase().includes("github.com") ? "GitHub" : (this.data.licensesBuild[index].repository.toLowerCase().includes("gitlab.com") ? "GitLab" : "Unknown")
43+
repoType: (() => {
44+
try {
45+
const url = new URL(this.data.licensesBuild[index].repository);
46+
const host = url.host.toLowerCase();
47+
if (host === "github.com") return "GitHub";
48+
if (host === "gitlab.com") return "GitLab";
49+
} catch (e) {
50+
console.error("Invalid URL:", e);
51+
}
52+
return "Unknown";
53+
})()
4454
})
4555
}, onUnload() {
4656
this.storeBindings.destroyStoreBindings();

0 commit comments

Comments
 (0)