From 3de6a5f14023bf75e89f8e6d03cc35b2469a7517 Mon Sep 17 00:00:00 2001 From: oluceps Date: Mon, 11 Nov 2024 07:01:39 +0800 Subject: [PATCH] ~ fix placeholder length --- src/helper/template.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/helper/template.rs b/src/helper/template.rs index 43f2843..63fbf43 100644 --- a/src/helper/template.rs +++ b/src/helper/template.rs @@ -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("{{ "), @@ -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; } @@ -55,6 +58,7 @@ mod tests { use super::*; use hex_literal::hex; use nom::AsBytes; + use spdlog::warn; #[test] fn parse_template_single() { @@ -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),