Repository navigation
Studio: fix Claude API reference pages in the browser panel - #14323
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48d00bab59
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const base = args.length > 1 ? String(args[1]) : ""; | ||
| if (base === "null") args = [args[0], new NativeURL(pageUrl).origin]; | ||
| else if (/^about:srcdoc(?=[?#]|$)/.test(base)) args = [args[0], pageUrl]; | ||
| else if (args.length === 1 && String(args[0]) === "null") args = [new NativeURL(pageUrl).origin]; |
There was a problem hiding this comment.
Restrict the origin rewrite to the primitive string
When a page passes a missing value as new URL(null) (for example, while validating an optional URL), coercing the argument in this guard makes it indistinguishable from the opaque-origin string and returns the current page origin even though the native constructor throws. The unconditional String also invokes custom object stringifiers once before Reflect.construct, changing their behavior; compare directly with the primitive string "null" so only window.location.origin is rewritten.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Claude API-reference pages call
new URL(window.location.origin). In the browser panel’s opaque-origin srcdoc frame, that becomesnew URL("null")and throwsInvalid URL, leaving the site on its “Something went wrong” screen on direct load or navigation.The URL proxy added in #14279 already rewrites opaque origins used as the second argument, but misses this one-argument form. Map that form to the current page’s origin too.
Verification
TypeError: Invalid URLwith inputnull.browser-url,browser-network,browser-page-storage,browser-frame-message, andbrowser-address.git diff --checkpass.Test command:
node --experimental-strip-types --test studio/frontend/tests/browser-{url,network,page-storage,frame-message,address}.test.ts