Repository navigation
fix(ui): keep a relative URL as recorded in Mock this request - #289
Merged
Merged
Conversation
Mock this request built the rule's URL pattern by resolving the call's URL against a dummy origin, which put a slash in front of a relative URL. A call to api/heroes?page=2 got the pattern /api/heroes?page=2, and since patterns without * match as a substring of the request URL, the rule never fired. Only absolute URLs lose their origin now; a relative URL stays as the app wrote it.
Contributor
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
# Conflicts: # extension/ui/assets/browser-agent-rpc-BXhoSh1z-Bpd00b-y.js # extension/ui/assets/browser-agent-rpc-BXhoSh1z-CQUbrXfP.js # extension/ui/assets/browser-agent-rpc-BXhoSh1z-CU2PEOZW.js # extension/ui/assets/index-BbaJhK0y.js # extension/ui/assets/index-Bc_tTXxC.js # extension/ui/assets/index-CgvJVwtz.js # extension/ui/index.html
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.
What and why
Mock this request in the SSR & HTTP tab fills the rule form from a recorded call. It built the URL pattern with
pathOf(), which resolves the URL against a dummy origin and returnspathname + search. That puts a/in front of a relative URL. A call toapi/heroes?page=2(relative URLs like this are common, for example in the Tour of Heroes tutorial) got the pattern/api/heroes?page=2.Rule patterns without
*match as a substring ofreq.urlWithParams, andapi/heroes?page=2doesn't contain/api/heroes?page=2. So the rule was saved and listed but never fired, on the client or during SSR, with nothing explaining why.mockPatternnow strips the origin only from absolute URLs (with a scheme, or starting with//). A relative URL stays as recorded, which still matches the absolute SSR URL as a substring. Redacted values still become*.How it was verified
New test in
app/src/__tests__/network-response-preview.test.ts. Onmainthe pattern is/api/heroes?page=2. With the fix it'sapi/heroes?page=2. All panel and package tests pass.pnpm commit:check(commit messages follow the guidelines)pnpm format:checkpnpm typecheck(includes thengctemplate checks)pnpm test:panelandpnpm test:devtools(all passing)pnpm skills:check(when.claude/changed): not changedapps/docsupdated (one sentence ininspectors/ssr-http.md)pnpm extension:buildandextension/uicommittedSummary by CodeRabbit