-
Notifications
You must be signed in to change notification settings - Fork 38.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes gh-32920
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,6 +196,16 @@ void fromUriString() { | |
assertThat(result.getQuery()).isNull(); | ||
assertThat(result.getFragment()).isEqualTo("baz"); | ||
|
||
result = UriComponentsBuilder.fromUriString("mailto:[email protected]?subject=foo").build(); | ||
assertThat(result.getScheme()).isEqualTo("mailto"); | ||
assertThat(result.getUserInfo()).isNull(); | ||
assertThat(result.getHost()).isNull(); | ||
assertThat(result.getPort()).isEqualTo(-1); | ||
assertThat(result.getSchemeSpecificPart()).isEqualTo("[email protected]?subject=foo"); | ||
assertThat(result.getPath()).isNull(); | ||
assertThat(result.getQuery()).isNull(); | ||
assertThat(result.getFragment()).isNull(); | ||
|
||
result = UriComponentsBuilder.fromUriString("docs/guide/collections/designfaq.html#28").build(); | ||
assertThat(result.getScheme()).isNull(); | ||
assertThat(result.getUserInfo()).isNull(); | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,8 +61,31 @@ private void testParse(String input, String scheme, @Nullable String host, @Null | |
else { | ||
assertThat(result.port()).as("Port is not null").isNull(); | ||
} | ||
assertThat(result.hasOpaquePath()).as("Result has opaque path").isFalse(); | ||
assertThat(result.path().toString()).as("Invalid path").isEqualTo(path); | ||
assertThat(result.query()).as("Invalid query").isEqualTo(query); | ||
assertThat(result.fragment()).as("Invalid fragment").isEqualTo(fragment); | ||
} | ||
|
||
@Test | ||
void parseOpaque() { | ||
testParseOpaque("mailto:[email protected]?subject=foo", "[email protected]", "subject=foo"); | ||
|
||
} | ||
|
||
void testParseOpaque(String input, String path, @Nullable String query) { | ||
UrlParser.UrlRecord result = UrlParser.parse("mailto:[email protected]?subject=foo", EMPTY_URL_RECORD, null, null); | ||
|
||
|
||
assertThat(result.scheme()).as("Invalid scheme").isEqualTo("mailto"); | ||
assertThat(result.hasOpaquePath()).as("Result has no opaque path").isTrue(); | ||
assertThat(result.path().toString()).as("Invalid path").isEqualTo(path); | ||
if (query != null) { | ||
assertThat(result.query()).as("Query is null").isNotNull(); | ||
assertThat(result.query()).as("Invalid query").isEqualTo(query); | ||
} | ||
else { | ||
assertThat(result.query()).as("Query is not null").isNull(); | ||
} | ||
} | ||
} |