buildClearURL 丢弃 URL hash#46
Conversation
buildClearURL now preserves the #fragment portion of the original URL when clearing query parameters, ensuring hash-based routing is not lost. Closes #11
Address review feedback: add test for URL with only fragment and no query params (/#section with removeKey=q) to verify fragment is preserved when there are no query parameters.
|
无遗漏 Issue #11 的 spec 范围清晰且局限:仅让 实现完整覆盖了所有要求:
|
|
所有测试通过, 可合并 总结
阻塞项:无 建议项:
|
…arURL
Replace string concatenation with url.URL{}.String() to properly handle
special characters in URL fragments. Add test case for special character
encoding.
|
无遗漏 Issue #11 的 spec 范围清晰且局限:仅让 实现完整覆盖了所有要求:
|
|
可合并 总结该 PR 以 minimal 且正确的方式修复了 阻塞项:无 建议项:
|
|
无遗漏 Issue #11 的 spec 范围极为局限:仅修复
实现方式( |
|
现在确认了实际的 PR diff(使用三点语法),仅有 可合并 总结PR 正确修复了 阻塞项:无 建议项:
|






Problem
buildClearURLininternal/server/server.go:718stripped the URL hash fragment when constructing redirect URLs. After removing a query parameter, the function returned only/or/?remaining=params, discarding any#fragmentportion of the original URL. While hash fragments are not sent to the server in normal HTTP requests, they can appear when the server constructs redirect targets from theRefererheader or similar sources.Approach
Preserve
u.Fragmentthrough the redirect URL construction. The function now captures the fragment before stripping query params, then appends#fragmentto the result in both code paths — when no query params remain (/#fragment) and when some remain (/?params#fragment). Cases where the fragment is empty are left unchanged.The change is two conditional blocks in
buildClearURL(internal/server/server.go:721-729), no other callers are affected.Tests
Added
TestBuildClearURLininternal/server/server_test.gocovering seven table-driven cases:///?tag=foo/#section/?tag=foo#section/?tag=foo#section/#sectionCloses #11