Skip to content

Commit

Permalink
more complete
Browse files Browse the repository at this point in the history
  • Loading branch information
farooqkz committed Feb 6, 2024
1 parent fbb2652 commit b06f247
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/parser/parse_from_text/link_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,26 @@ fn ls32(input: &str) -> IResult<&str, &str> {
fn ipv6(input: &str) -> IResult<&str, &str> {
let h16_and_period = tuple(h16, char(':'));
let double_period = tag("::");
tuple(
take_while_m_n(6, 6, h16_and_period),
alt(ls32, double_period),
take_while(5, 5, h16_and_period),
alt(ls32, opt(h16)),
double_period,
take_while(4, 4, h16_and_period),
alt(ls32, opt(tuple(take_while_m_n(0, 1, h16_and_period)

let mut n: usize = 0;
let s = String::to_owned();
loop {
let Ok((input, part)) = h16_and_period(input) else {
if n == 6 {
break;
} else {
let Ok((input, part)) = double_period(input) else {
return Err(CustomError::NoContent);
};
n += 1;
s.push_str(part);
}
};
n += 1;
s.push_str(part);
}
let (input, part) = ls32(input)?;
s.push_str(part);
Ok((input, s))
}


Expand All @@ -125,7 +136,7 @@ fn is_ipvfuture_last(c: char) -> bool {
}

fn ipvfuture(input: &str) -> IResult<&str, &str> {
tuple(char('v'), take_while_m_n(1, 1, is_hex_digit), char('.'), take_while_m_n(1, 1, is_ipvfuture_last))
tuple(char('v'), take_while_m_n(1, 1, is_hex_digit), char('.'), take_while_m_n(1, 1, is_ipvfuture_last))(input)
}


Expand Down Expand Up @@ -220,7 +231,7 @@ fn link(input: &str) -> IResult<&str, Element, CustomError<&str>> {
destination: LinkDestination {
target: input,
hostname: Some(hostport),
punycode: ,
punycode: None,
scheme: scheme
}
}
Expand Down

0 comments on commit b06f247

Please sign in to comment.