Skip to content

Commit

Permalink
fix #76
Browse files Browse the repository at this point in the history
  • Loading branch information
farooqkz committed Jun 8, 2024
1 parent af5c597 commit 62c9550
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/parser/link_url/parse_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ fn iauthority(input: &str) -> IResult<&str, (&str, &str, bool), CustomError<&str
let (input, port) = opt(recognize(tuple((char(':'), take_while(is_digit)))))(input)?;
let userinfo = userinfo.unwrap_or("");
let port = port.unwrap_or("");
let len = userinfo.len().saturating_add(port.len());
let len = userinfo.len()
.saturating_add(port.len());

if let Some(out) = i.get(0..len) {
Ok((input, (out, host, is_ipv6_or_future)))
} else {
Expand All @@ -142,10 +144,10 @@ fn iauthority(input: &str) -> IResult<&str, (&str, &str, bool), CustomError<&str

/// Consume an iuserinfo
fn take_while_iuserinfo(input: &str) -> IResult<&str, &str, CustomError<&str>> {
alt((
recognize(many0(take_while_pct_encoded)),
take_while(is_iuserinfo_not_pct_encoded),
))(input)
recognize(many1(alt((
recognize(many1(take_while_pct_encoded)),
take_while1(is_iuserinfo_not_pct_encoded),
))))(input)
}

fn is_iuserinfo_not_pct_encoded(c: char) -> bool {
Expand Down
1 change: 1 addition & 0 deletions tests/links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,5 @@ fn dclogin_link() {
assert!(link_destination.punycode.is_none());
assert_eq!(link_destination.scheme, "dclogin");
assert_eq!(link_destination.target, link);
assert_eq!(link_destination.hostname, Some("nine.testrun.org"));
}

0 comments on commit 62c9550

Please sign in to comment.