Normalize pasted Zendesk subdomain URLs

Pasting a full Zendesk URL with a path or query (e.g.
acme.zendesk.com/agent?x=1) left the trailing segments in place because
the .zendesk.com suffix no longer matched at the end, producing an
invalid site value rejected by the backend. Drop everything from the
first path/query/fragment separator before stripping the suffix.

Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
Aurélien Sibiril
2026-06-04 18:51:58 +02:00
parent bb6a961b12
commit bc53f603eb

View File

@@ -177,7 +177,9 @@ function hasRequiredExtraSettings(
function cleanZendeskSubdomain(raw: string): string { function cleanZendeskSubdomain(raw: string): string {
let value = raw.trim(); let value = raw.trim();
value = value.replace(/^https?:\/\//i, ""); value = value.replace(/^https?:\/\//i, "");
value = value.replace(/\/+$/, ""); // Drop any path, query, or fragment from a pasted URL/host so only the
// host label survives (e.g. "acme.zendesk.com/agent?x=1" -> "acme").
value = value.replace(/[/?#].*$/, "");
value = value.replace(/\.zendesk\.com$/i, ""); value = value.replace(/\.zendesk\.com$/i, "");
return value.trim(); return value.trim();
} }