pub fn link_strict<'a, E>(
input: &'a str,
) -> Result<Vec<Option<LinkData<'a>>>, LinkParseError>
Expand description
This method will parse a &str
and return an array of Option
s if it can
successfully parse the &str
as a Link header.
The reason we return Option
s is because if the Link header has empty elements, we want to show that information
to the user by returning None
s.
use nom_rfc8288::complete::{link_strict, LinkData, LinkParam};
let link_data = r#"<https://example.com>; rel="origin"; csv="one,two""#;
let parsed = link_strict(link_data).unwrap();
assert_eq!(
parsed,
vec![
Some(
LinkData {
url: "https://example.com",
params: vec![
LinkParam {
key: "rel",
val: Some("origin".to_owned()),
},
LinkParam {
key: "csv",
val: Some("one,two".to_owned()),
}
],
}
),
]
);