Potential fix for code scanning alert no. 1043: Incomplete URL substring sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Charles de Dreuille <charles.dedreuille@gmail.com>
This commit is contained in:
Charles de Dreuille
2025-03-24 17:53:57 +00:00
committed by GitHub
parent b06f680a99
commit 43a5ff532c
@@ -98,7 +98,8 @@ async function submitForm(value: string) {
try {
const url = new URL(value);
if (url.hostname.endsWith('example.com')) {
const allowedHosts = ['example.com', 'beta.example.com', 'www.example.com'];
if (!allowedHosts.includes(url.hostname)) {
return { error: 'The example domain is not allowed' };
}
} catch {