     }
                }
                
                // Check if there are any query parameters to preserve
                const currentParams = window.location.search;
                if (currentParams && !currentParams.includes('redirect=')) {
                    const potentialUrl = `/${currentParams}`;
                    if (isValidRedirectUrl(potentialUrl)) {
                        return potentialUrl;
                    }
                }
                
                return '/';
        