Ensure that the URI resolution semantic is consistent with Dart - #819
Merged
Conversation
stof
force-pushed
the
test_uri_resolution
branch
from
November 5, 2025 22:06
0b6994d to
9280fd3
Compare
The dart `Uri.resolve` API implements 3 behaviors that differ from the RFC3986 resolution algorithm: 1. when resolving a relative path reference against a base URI with a scheme, no authority and a relative path, it treats it as if the base URI path was absolute (which seems to violate the behavior of the RFC) 2. it supports resolving a relative path reference against a relative path base URL (instead of being an error case in the RFC3986) by merging the relative paths together to produce a new relative path (which preserves leading `..` segments, unlike usual path resolution on absolute URLs) 3. it supports resolving any kind of reference against a base URI without a scheme (for cases other than the previous case) by applying the algorithm of RFC3986 with an undefined scheme instead of a defined scheme (producing an undefined scheme in the result). Case 1 and 2 are now implemented in our `UriUtil` to match the Dart behavior. The case 3 is covered already by the logic available in `league/uri` 7.5, which is why this inconsistency was not discovered until now. Making that logic compatible with `league/uri` 7.6 (which performs strict validation of the RFC3986 algorithm) will be done separately.
stof
force-pushed
the
test_uri_resolution
branch
from
November 6, 2025 02:11
9280fd3 to
0107fd9
Compare
stof
marked this pull request as ready for review
November 6, 2025 02:11
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.
Uri.resolveUriin Dart implements some behavior that is not part of the "Transform reference" algorithm of the RFC 3986 (which leaves some cases undefined behavior): https://github.com/dart-lang/sdk/blob/eaa7368470e2570bab8c9526803f8f20bdf29906/sdk/lib/core/uri.dart#L810-L823We need to ensure that our
UrlUtilimplements the Dart semantic for this algorithm to keep our porting work simple (encapsulating that logic in a single place), including when upgradingleague/uri(as discussed in #808, version 7.6 will become stricter).The dart
Uri.resolveAPI implements 3 behaviors that differ from the RFC3986 resolution algorithm:..segments, unlike usual path resolution on absolute URLs)Case 1 and 2 are now implemented in our
UriUtilto match the Dart behavior. The case 3 is covered already by the logic available inleague/uri7.5, which is why this inconsistency was not discovered until now.Making that logic compatible with
league/uri7.6 (which performs strict validation of the RFC3986 algorithm) will be done separately.