* cron: split webhook delivery from announce mode * cron: validate webhook delivery target * cron: remove legacy webhook fallback config * fix: finalize cron webhook delivery prep (#17901) (thanks @advaitpaliwal) --------- Co-authored-by: Tyler Yust <TYTYYUST@YAHOO.COM>
23 lines
492 B
TypeScript
23 lines
492 B
TypeScript
function isAllowedWebhookProtocol(protocol: string) {
|
|
return protocol === "http:" || protocol === "https:";
|
|
}
|
|
|
|
export function normalizeHttpWebhookUrl(value: unknown): string | null {
|
|
if (typeof value !== "string") {
|
|
return null;
|
|
}
|
|
const trimmed = value.trim();
|
|
if (!trimmed) {
|
|
return null;
|
|
}
|
|
try {
|
|
const parsed = new URL(trimmed);
|
|
if (!isAllowedWebhookProtocol(parsed.protocol)) {
|
|
return null;
|
|
}
|
|
return trimmed;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|