Repository navigation
nav 堵搜索框当前页跳转的 Referer(外科式,noreferrer 锚点) - #36
Merged
Merged
Conversation
Same-tab search now navigates through a temporary rel="noreferrer" anchor instead of window.location.href, so the engine no longer receives this site's origin. New-tab path and other outbound links are untouched; tests assert the anchor contract and that location is never written. Checkpoint: c_hgEIUTPf23SAyywVp-J
This was referenced Nov 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
searchNewTab=false)时唯一一处 Referer 泄漏:原来走window.location.href,浏览器按默认策略(strict-origin-when-cross-origin)会把本站 origin 发给搜索引擎。<a rel="noreferrer" target="_self">点击完成,rel="noreferrer"只作用于这一次导航;新标签搜索、链接卡片等其它外跳与图标/壁纸等资源加载的行为一律不变,也未引入页面级<meta name="referrer">。Changes
navigateSameTabWithoutReferrer(url):建锚点 → 设rel="noreferrer"→ 插入body→ 点击 → 立即移除。submit()的当前页分支由window.location.href = url改为调用该函数;新标签分支window.open(url, "_blank", "noopener,noreferrer")一行未动。window.location桩改为带写入计数:同页跳转若退回location.href,断言立刻失败。rel="noreferrer"、target="_self"、href正确、点完已移出 DOM;新标签用例断言不写 location、不点锚点;另加 helper 的直接单测与空查询不点锚点。searchNewTab=false的集成用例改为断言锚点契约(PublicPage全链路渲染),不再断言 location 被改写。Testing
workflow_dispatch,commitbe52861):success,Lint / Format check / Type check / Build / Test 全部通过 — https://github.com/WorkerHub/nav/actions/runs/42220884446 ;其中 worker 193 用例、web 213 用例通过。searchNewTab=false:修复前referer: http://localhost:57649/→ 修复后referer: null,且页面确实完成跳转。searchNewTab=true:修复前后均referer: null、起始页不动,行为不变。pnpm lint(退出码 0,仅存量 warning)、format:check、typecheck、build、test全绿。rel="noreferrer"同样强制 no-referrer。