diff --git a/src/lib.rs b/src/lib.rs index fee5985..7f00284 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1016,6 +1016,8 @@ mod tests { format(input, &QueryParams::Indexed(params), options), expected ); + + format("?62666666121266666612", &QueryParams::None, options); } #[test] diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 0e369c8..3f480d2 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -301,12 +301,16 @@ fn get_indexed_placeholder_token(input: &str) -> IResult<&str, Token<'_>> { Token { kind: TokenKind::Placeholder, value: token, - key: if token.starts_with('$') { - let index = token[1..].parse::().unwrap(); - Some(PlaceholderKind::OneIndexed(index)) - } else if token.len() > 1 { - let index = token[1..].parse::().unwrap(); - Some(PlaceholderKind::ZeroIndexed(index)) + key: if token.len() > 1 { + if let Ok(index) = token[1..].parse::() { + Some(if token.starts_with('$') { + PlaceholderKind::OneIndexed(index) + } else { + PlaceholderKind::ZeroIndexed(index) + }) + } else { + None + } } else { None },