Skip to content

Commit

Permalink
Merge pull request #63 from robinst/empty-path-with-query
Browse files Browse the repository at this point in the history
Support URIs with empty path but with query
  • Loading branch information
robinst committed Jun 24, 2023
2 parents 7497ae2 + 1ac3d2f commit 00a8560
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fn find_url_end(s: &str, quote: Option<char>, iri_parsing_enabled: bool) -> Opti
let mut previous_can_be_last = true;
let mut end = Some(0);

if !s[0..].starts_with("/") {
if !s[0..].starts_with("/") && !s[0..].starts_with("?") {
return Some(0);
}

Expand Down
12 changes: 12 additions & 0 deletions tests/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,18 @@ E-Mail:
);
}

#[test]
fn uri_with_empty_path_and_with_query() {
assert_linked(
"upi://pay?pa=XXXXXXX&pn=XXXXX",
"|upi://pay?pa=XXXXXXX&pn=XXXXX|",
);
assert_linked(
"https://example.org?pa=XXXXXXX&pn=XXXXX",
"|https://example.org?pa=XXXXXXX&pn=XXXXX|",
);
}

#[test]
fn fuzz() {
assert_not_linked("ab:/ϸ");
Expand Down

0 comments on commit 00a8560

Please sign in to comment.