v0.35.0
This commit is contained in:
1 parent
2c03fcf248
commit
d3b492874b
95 files changed
+1628
-743
No files matched your search
@@ -217,24 +217,24 @@ fn matching_scopes<'a>(compiled: &'a Compiled, path: &str) -> Vec<&'a Scope> {
|
||||
|
||||
pub fn denied(compiled: Option<&Compiled>, path: &str) -> bool {
|
||||
let Some(compiled) = compiled else { return false; };
|
||||
matching_scopes(compiled, path).into_iter().filter_map(|scope| scope.deny_all).last().unwrap_or(false)
|
||||
matching_scopes(compiled, path).into_iter().filter_map(|scope| scope.deny_all).next_back().unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn index_files<'a>(compiled: Option<&'a Compiled>, directory_components: &[String], fallback: &'a [String]) -> &'a [String] {
|
||||
let Some(compiled) = compiled else { return fallback; };
|
||||
compiled.scopes.iter().filter(|scope| scope_matches(scope, directory_components)).filter_map(|scope| scope.directory_index.as_deref()).last().unwrap_or(fallback)
|
||||
compiled.scopes.iter().filter(|scope| scope_matches(scope, directory_components)).filter_map(|scope| scope.directory_index.as_deref()).next_back().unwrap_or(fallback)
|
||||
}
|
||||
|
||||
pub fn directory_listing(compiled: Option<&Compiled>, directory_components: &[String], fallback: bool) -> bool {
|
||||
let Some(compiled) = compiled else { return fallback; };
|
||||
compiled.scopes.iter().filter(|scope| scope_matches(scope, directory_components)).filter_map(|scope| scope.directory_listing).last().unwrap_or(fallback)
|
||||
compiled.scopes.iter().filter(|scope| scope_matches(scope, directory_components)).filter_map(|scope| scope.directory_listing).next_back().unwrap_or(fallback)
|
||||
}
|
||||
|
||||
pub fn mime_type(compiled: Option<&Compiled>, path: &Path) -> Option<HeaderValue> {
|
||||
let compiled = compiled?;
|
||||
let extension = path.extension()?.to_str()?.to_ascii_lowercase();
|
||||
let path_text = path.to_string_lossy();
|
||||
matching_scopes(compiled, &path_text).into_iter().filter_map(|scope| scope.mime_types.get(&extension).cloned()).last()
|
||||
matching_scopes(compiled, &path_text).into_iter().filter_map(|scope| scope.mime_types.get(&extension).cloned()).next_back()
|
||||
}
|
||||
|
||||
pub fn php_extension(compiled: Option<&Compiled>, path: &Path) -> bool {
|
||||
@@ -345,8 +345,8 @@ async fn condition_matches(condition: &RewriteCondition, service: &CompiledServi
|
||||
ConditionMatcher::Regex { regex, negate } => {
|
||||
if let Some(captures) = regex.captures(&value) {
|
||||
let values = captures.iter().map(|value| value.map(|v| v.as_str().to_owned()).unwrap_or_default()).collect::<Vec<_>>();
|
||||
(if *negate { false } else { true }, if *negate { Vec::new() } else { values })
|
||||
} else { (if *negate { true } else { false }, Vec::new()) }
|
||||
(!*negate, if *negate { Vec::new() } else { values })
|
||||
} else { (*negate, Vec::new()) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user