diff options
Diffstat (limited to 'cli/lsp/path_to_regex.rs')
-rw-r--r-- | cli/lsp/path_to_regex.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/cli/lsp/path_to_regex.rs b/cli/lsp/path_to_regex.rs index 16db88194..ef782c4db 100644 --- a/cli/lsp/path_to_regex.rs +++ b/cli/lsp/path_to_regex.rs @@ -249,7 +249,11 @@ impl StringOrVec { } } - pub fn to_string(&self, maybe_key: Option<&Key>) -> String { + pub fn to_string( + &self, + maybe_key: Option<&Key>, + omit_initial_prefix: bool, + ) -> String { match self { Self::String(s) => s.clone(), Self::Vec(v) => { @@ -262,8 +266,12 @@ impl StringOrVec { ("/".to_string(), "".to_string()) }; let mut s = String::new(); - for segment in v { - s.push_str(&format!("{}{}{}", prefix, segment, suffix)); + for (i, segment) in v.iter().enumerate() { + if omit_initial_prefix && i == 0 { + s.push_str(&format!("{}{}", segment, suffix)); + } else { + s.push_str(&format!("{}{}{}", prefix, segment, suffix)); + } } s } |