Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/keychain/src/utils/url-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
export function validateRedirectUrl(redirectUrl: string): {
isValid: boolean;
error?: string;
validatedUrl?: string;
} {
// Check for empty or undefined
if (!redirectUrl || redirectUrl.trim() === "") {
Expand Down Expand Up @@ -66,7 +67,7 @@ export function validateRedirectUrl(redirectUrl: string): {
}

// URL is safe to redirect to
return { isValid: true };
return { isValid: true, validatedUrl: url.href };
}

/**
Expand All @@ -88,6 +89,7 @@ export function safeRedirect(redirectUrl: string): boolean {
}

// Safe to redirect
window.location.href = redirectUrl;
// Use the canonical, validated URL instead of the raw input
window.location.href = validation.validatedUrl!;
return true;
}
Loading