Repository navigation
test(core): capture how docusaurus serve handles hand-typed URLs (AI-assisted) - #12881
Conversation
…assisted) fetch() normalizes request URLs like browsers do, so the tests could not send a #hash or a ".." segment. Hand-typed requests can, and the serve request handler sees them as-is. A new test option sends the first request with http.get() to capture this behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
✅ [V2]
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Size Change: 0 B Total Size: 12.1 MB ℹ️ View Unchanged
|
⚡️ Lighthouse report for the deploy preview of this PR
|
|
Size Change: 0 B Total Size: 12.1 MB ℹ️ View Unchanged
|
…ted) Hand-typed URLs whose ".." segments resolve to "//example.com" must not redirect to another host. The tests also never follow redirects to other hosts, so a regression can't make them send network requests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Motivation
The tests of #12858 send requests with
fetch(), which normalizes URLs like browsers do: it resolves.and..segments (%2E%2Eincluded) and drops the#hash. Hand-typed requests can send these URLs as-is, and Node passes them untouched to thedocusaurus serverequest handler.A new
asIstest option sends the first request withhttp.get(), which keeps the path as-is. Redirects are still followed withfetch(), like a browser does. New snapshot tables capture how these URLs are served under abaseUrl. Several of them land on the homepage, because the serve-handler redirects drop thebaseUrl:/base/file.html#hash→301 /file→ homepagetrailingSlash: true,/base/file.html#hash→302 /base/file.html/#hash→ 404 (Windows servesfile.html)Two rows capture open redirect attempts like
/base/..//example.com/index, whichmaindoesn't redirect to another host. The tests never follow redirects to other hosts, so a regression can't make them send network requests.This captures the behavior before #12879 and #12877, which parse the request URL with the WHATWG URL parser, so their diffs show how these URLs change.
Test Plan
pnpm test packages/docusaurus/src/commands/serve. The Windows CI checks the Windows snapshot, where file URLs with a trailing slash serve the file instead of a 404, like in the existing Windows snapshot.Test links
Deploy preview: https://deploy-preview-12881--docusaurus-2.netlify.app/
Related issues/PRs
docusaurus serveclean URL redirects keep the baseUrl (AI-assisted) #12879 and fix(core):docusaurus serveno longer adds a trailing slash to some assets under a baseUrl (AI-assisted) #12877(AI-assisted)
🤖 Generated with Claude Code
Summary by CodeRabbit