Skip to content

Commit

Permalink
~ fix placeholder length
Browse files Browse the repository at this point in the history
  • Loading branch information
oluceps committed Nov 10, 2024
1 parent b86c4c0 commit 3de6a5f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/helper/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use nom::{
IResult,
};

// 4 braces and 64 bits hash
const PLACEHOLDER_LENGTH: usize = 70;

fn parse_braced_hash(input: &str) -> IResult<&str, &str, Error<&str>> {
delimited(
tag("{{ "),
Expand All @@ -17,7 +20,7 @@ fn parse_braced_hash(input: &str) -> IResult<&str, &str, Error<&str>> {
}

pub fn extract_all_hashes<'a>(input: &'a str, res: &mut Vec<&'a str>) {
if input.len() < 66 {
if input.len() < PLACEHOLDER_LENGTH {
// less than expected `{{ hash }}` length
return;
}
Expand Down Expand Up @@ -55,6 +58,7 @@ mod tests {
use super::*;
use hex_literal::hex;
use nom::AsBytes;
use spdlog::warn;

#[test]
fn parse_template_single() {
Expand Down Expand Up @@ -91,6 +95,7 @@ mod tests {
#[test]
fn parse_template_with_trailing_white() {
let str = "{{ cd789434d890685da841b8db8a02b0173b90eac3774109ba9bca1b81440a2a93 }} ";
warn!("{}", str.len());

let t = Template {
content: String::from(str),
Expand Down

0 comments on commit 3de6a5f

Please sign in to comment.