fix(android): match the dev server by host and port - #729
Merged
Merged
Conversation
The dev-server navigation check compared hosts only, so any port on the dev server's host loaded in the WebView. That also failed GutenbergViewTest when GUTENBERG_EDITOR_URL pointed at 10.0.2.2. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
XCFramework BuildThis PR's XCFramework is available for testing. Add the following to your .package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/729")Built from 97bbdc3 |
dcalhoun
marked this pull request as ready for review
September 24, 2026 16:48
Contributor
|
@dcalhoun I haven't tested this yet, but Claude had some findings:
|
A schemeless GUTENBERG_EDITOR_URL has no authority, so it matched host-less URLs like mailto: and loaded them in the WebView instead of externally. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
Author
|
Thank you, @nbradbury. Let me know if you have any concerns with the way each are addressed below. Ready for another review.
|
Contributor
|
@dcalhoun Changes look good to me and I'll approve. Claude did report some other issues, but sometimes I think it's just looking for trouble :) I'll leave them here for you to look over.
|
Properties keeps trailing whitespace, so a stray space after the port made Uri drop it and the dev server check never match. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
Author
|
Fixed the trailing-space case in 97bbdc3. The rest are pre-existing or quite low impact. The host case was deferred in an earlier comment given it impacts production loading. |
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?
Match dev server requests by host and port.
Why?
Matching by host alone can cause mismatching (e.g., dev server vs local wp-env server). It also led to Android unit test failures if the
GUTENBERG_EDITOR_URLproperty was set during a test run.How?
Rely upon the existing
originAuthorityhelper to match dev server requests.Testing Instructions
Smoke test the Android editor when using the local dev server
GUTENBERG_EDITOR_URLin yourlocal.propertiesfile.Verify
GutenbergViewTestpass withGUTENBERG_EDITOR_URLsetGUTENBERG_EDITOR_URLin yourlocal.propertiesfile.make test-android-library-unitresults in aGutenbergViewTest > shouldOverrideUrlLoadingpassing outcome. The sixHttpServerAuthenticationTestsfailures are unrelated and addressed in test(android): send Proxy-Authorization via OkHttp in auth tests #728.Accessibility Testing Instructions
N/A, no user-facing changes.
Screenshots or screencast
N/A, no user-facing changes.
AI-generated details
When
GUTENBERG_EDITOR_URLis set inandroid/local.properties,shouldOverrideUrlLoadingcompared only the dev server's host. Any port on that host loaded inside the WebView, unlike the asset and REST API checks, which compare host and port. It also madeGutenbergViewTest's "blocks asset path URLs that drop the site's port" test fail locally whenever the dev server was on10.0.2.2.The check now compares origin authorities (host and port) via the existing
originAuthority()helper, in a newisDevServerUrl()function with its own tests. Published builds are unaffected becauseGUTENBERG_EDITOR_URLis empty there.To reproduce the old failure, add
GUTENBERG_EDITOR_URL=http://10.0.2.2:5173/toandroid/local.propertiesand runmake test-android-library-unit. It passes on this branch; remove the line afterwards. The sixHttpServerAuthenticationTestsfailures on patched JDKs are unrelated and fixed separately in #728.🤖 Generated with Claude Code