From dbb6c0d2bea2a3bc06de2b02d98d9b3d9e1cb435 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 04:19:40 +0000 Subject: [PATCH] Fix: Preserve ?v= parameter when auto-redirecting to For You feed When a user visits a direct video link (e.g. `/?v=...`) while logged in, the application auto-authenticates and redirects the view to `#view=for-you`. Previously, `setHashView` unconditionally removed all query parameters, causing the video modal to fail to open because the `v` parameter was lost before it could be read. This change: 1. Updates `setHashView` to accept an options object, allowing specific parameters to be preserved. 2. Updates `handleAuthLogin` in `app.js` to detect if a `v` parameter is present and request its preservation during the view switch. --- js/app.js | 5 ++++- js/hashView.js | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/js/app.js b/js/app.js index 58125cb4..b258e3ff 100644 --- a/js/app.js +++ b/js/app.js @@ -4332,8 +4332,11 @@ class Application { const currentView = getHashViewName(); const normalizedView = typeof currentView === "string" ? currentView.toLowerCase() : ""; + const urlParams = new URLSearchParams(window.location.search); + const hasVideoParam = urlParams.has("v"); + if (!normalizedView || normalizedView === "most-recent-videos") { - setHashView("for-you"); + setHashView("for-you", { preserveVideoParam: hasVideoParam }); } const rawProviderId = diff --git a/js/hashView.js b/js/hashView.js index e900f612..ee28e9c2 100644 --- a/js/hashView.js +++ b/js/hashView.js @@ -14,14 +14,16 @@ export function getHashViewName() { return viewName.trim(); } -export function setHashView(viewName) { +export function setHashView(viewName, options = {}) { if (typeof window === "undefined") { return; } const url = new URL(window.location.href); url.searchParams.delete("modal"); - url.searchParams.delete("v"); + if (!options?.preserveVideoParam) { + url.searchParams.delete("v"); + } const newUrl = url.pathname + url.search + `#view=${viewName}`; window.history.replaceState({}, "", newUrl);