Skip to content

Commit

Permalink
chore: Unify naming convention for compound values
Browse files Browse the repository at this point in the history
Signed-off-by: Arnau Siches <[email protected]>
  • Loading branch information
arnau committed Jun 9, 2019
1 parent 9320d61 commit efdb673
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::link::Link;
use crate::parser::Rule;
use pest::iterators::Pair;

/// A collection of links.
#[derive(Debug, PartialEq)]
pub struct Header {
pub links: Vec<Link>,
Expand Down Expand Up @@ -47,7 +48,7 @@ mod tests {

#[test]
fn wrong_rule_type() {
let input = r#"<https://example.org>"#;
let input = r#"<https://example.org> rel=next"#;

let rule = Rfc8288Parser::parse(Rule::link, &input)
.expect("unsuccessful parse")
Expand Down
2 changes: 1 addition & 1 deletion src/param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl Param {

Rule::quoted_value => value = Some(inner_pair.as_str().into()),

Rule::star_value => match &encoding {
Rule::pct_value => match &encoding {
Some(enc @ Encoding::Utf8) => {
let decoded_value =
percent_decode(inner_pair.as_str().as_bytes()).decode_utf8()?;
Expand Down
10 changes: 5 additions & 5 deletions src/rfc8288.pest
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ target = @{ (!(">") ~ char)* }
name = @{ (!("=" | "*") ~ char)+ }

// Expects a valid RFC8187 string
encoding = @{ (!("'") ~ char)+ }
language = @{ (!("'") ~ char)* }
star_value = @{ (pct_encoded | attr_char)+ }
star_group = _{ encoding ~ "'" ~ language ~ "'" ~ star_value }
encoding = @{ (!("'") ~ char)+ }
language = @{ (!("'") ~ char)* }
pct_value = @{ (pct_encoded | attr_char)+ }
compound_value = _{ encoding ~ "'" ~ language ~ "'" ~ pct_value }

// Expects a Token or a Quoted String
token_value = @{ (!("," | "\"") ~ char)* }
quoted_value = @{ (!("\"") ~ (ws | NEWLINE | char))* }
value = _{ (("\"" ~ quoted_value ~ "\"") | token_value) }

star_param = _{ name ~ "*" ~ (bws ~ "=" ~ bws ~ star_group)? }
star_param = _{ name ~ "*" ~ (bws ~ "=" ~ bws ~ compound_value)? }
param = { star_param | (name ~ (bws ~ "=" ~ bws ~ value)?) }

link = { "<" ~ target ~ ">" ~ (ows ~ ";" ~ ows ~ param)* }
Expand Down

0 comments on commit efdb673

Please sign in to comment.