aboutsummaryrefslogtreecommitdiff
path: root/src/shares.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/shares.rs')
-rw-r--r--src/shares.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/shares.rs b/src/shares.rs
index 9cfe156..4017e1f 100644
--- a/src/shares.rs
+++ b/src/shares.rs
@@ -1,7 +1,6 @@
-use std::{
- collections::HashMap,
- path::{Component, Path, PathBuf},
-};
+use std::collections::HashMap;
+
+use camino::{Utf8Component, Utf8Path, Utf8PathBuf};
/// Maps paths to access rules.
#[derive(Default, Debug)]
@@ -149,18 +148,18 @@ pub fn parse_shares_txt(text: &str) -> Result<Shares, String> {
// normalize path
let mut comps = Vec::new();
- for comp in Path::new(&*path).components() {
+ for comp in Utf8Path::new(&*path).components() {
match comp {
- Component::Normal(name) => comps.push(name),
- Component::ParentDir => {
+ Utf8Component::Normal(name) => comps.push(name),
+ Utf8Component::ParentDir => {
return Err(format!("line #{}: path may not contain ../", idx + 1))
}
_ => {}
}
}
- let path: PathBuf = comps.iter().collect();
- let path = path.to_str().unwrap();
+ let path: Utf8PathBuf = comps.iter().collect();
+ let path = path.as_str();
if let Some(stripped) = path.strip_suffix("/*") {
let pr = prefix_rules.entry(stripped.to_owned()).or_default();