diff --git a/src/component.rs b/src/component.rs index 4c6a4b8..b8516da 100644 --- a/src/component.rs +++ b/src/component.rs @@ -232,7 +232,7 @@ fn generate_pattern_string(part_list: &[&Part], options: &Options) -> String { kind: PartType::FixedText, value, .. - }) if value.chars().last().unwrap().to_string() == options.prefix_code_point + }) if !value.is_empty() && value.chars().last().unwrap().to_string() == options.prefix_code_point ) { needs_grouping = true; diff --git a/src/lib.rs b/src/lib.rs index d8fad56..1bd2fbd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1120,4 +1120,16 @@ mod tests { // Should use non-opaque canonicalization because of leading slash assert_eq!(myfile_pattern.pathname().to_string(), "/test"); } + + #[test] + fn issue72() { + let _ = ::parse( + UrlPatternInit { + pathname: Some("\\\n*\0".to_string()), + ..Default::default() + }, + Default::default(), + ) + .unwrap(); + } }