Repository navigation
Match path configuration rules against the normalized url - #223
Merged
Merged
Conversation
PathConfigurationData parsed the location with java.net.URL, which keeps a url exactly as written. The WebView and OkHttp normalize it before loading, so a url that isn't in canonical form could match different rules than the page it loads. http(s) locations now go through OkHttp's HttpUrl, which Hotwire already uses for origins. A url without a path keeps its empty path, and other schemes still use java.net.URL, so their matching doesn't change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The WebView removes tabs and newlines from the whole url, including the host, before it parses it. OkHttp only skips them in the path, so a url with one in its host fell back to java.net.URL. Now path() removes them first, and an http(s) url that still doesn't parse matches no rules. Whether a url has a path now comes from the text after its host, so "https://example.com\" matches the root path like the WebView loads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OkHttp drops a form feed from the path, while the WebView percent-encodes it, so "/files/\f../other" matched as "/other" but loaded as "/files/%0C../other". path() now encodes form feeds before OkHttp parses the url. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Path configuration rules now match an http(s) url in the same form the WebView loads it. Before,
PathConfigurationDataread the path withjava.net.URL, which keeps a url exactly as written, so a url that isn't in canonical form could get different properties than the page it loads.HttpUrl, which Hotwire already uses for origins. It reads backslashes as slashes and resolves dot segments. An http(s) url it can't parse matches no rules.^/$rules don't start matching a bare host.mailto:, still go throughjava.net.URL.^/café$, needs its encoded form,^/caf%C3%A9$, which is also how the WebView requests it. OkHttp encodes|and^in paths too, which the WebView keeps, so a rule that matches those literally needs%7Cand%5E.I checked every url literal in 3 apps' code and tests against the old and new parsing. Only urls with a trailing backslash differ, and those now match the way the WebView loads them.
🤖 Generated with Claude Code