Skip to content

Commit ec34485

Browse files
authored
Fix unwrap (#75)
1 parent a9d1862 commit ec34485

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/component.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ fn generate_pattern_string(part_list: &[&Part], options: &Options) -> String {
232232
kind: PartType::FixedText,
233233
value,
234234
..
235-
}) if value.chars().last().unwrap().to_string() == options.prefix_code_point
235+
}) if !value.is_empty() && value.chars().last().unwrap().to_string() == options.prefix_code_point
236236
)
237237
{
238238
needs_grouping = true;

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,4 +1120,16 @@ mod tests {
11201120
// Should use non-opaque canonicalization because of leading slash
11211121
assert_eq!(myfile_pattern.pathname().to_string(), "/test");
11221122
}
1123+
1124+
#[test]
1125+
fn issue72() {
1126+
let _ = <UrlPattern>::parse(
1127+
UrlPatternInit {
1128+
pathname: Some("\\\n*\0".to_string()),
1129+
..Default::default()
1130+
},
1131+
Default::default(),
1132+
)
1133+
.unwrap();
1134+
}
11231135
}

0 commit comments

Comments
 (0)