MCPcopy Create free account
hub / github.com/PerroEngine/Perro / validate_dlc_name

Function validate_dlc_name

perro_source/devtools/perro_cli/src/scaffold.rs:156–174  ·  view source on GitHub ↗
(raw: &str)

Source from the content-addressed store, hash-verified

154}
155
156pub(crate) fn validate_dlc_name(raw: &str) -> Result<String, String> {
157 let dlc = raw.trim();
158 if dlc.is_empty() {
159 return Err("dlc name cannot be empty".to_string());
160 }
161 if dlc.eq_ignore_ascii_case("self") {
162 return Err("dlc name `self` is reserved".to_string());
163 }
164 if dlc.contains('/') || dlc.contains('\\') {
165 return Err("dlc name must not include path separators".to_string());
166 }
167 if Path::new(dlc)
168 .components()
169 .any(|c| matches!(c, std::path::Component::ParentDir))
170 {
171 return Err("dlc name must not include `..` segments".to_string());
172 }
173 Ok(dlc.to_string())
174}
175
176fn resolve_content_root(project_dir: &Path, args: &[String]) -> Result<PathBuf, String> {
177 if let Some(raw_dlc) = parse_flag_value(args, "--dlc") {

Callers 4

resolve_content_rootFunction · 0.70
resolve_content_prefixFunction · 0.70
new_dlc_commandFunction · 0.70
dlc_commandFunction · 0.70

Calls 3

anyMethod · 0.80
is_emptyMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected