|
@@ -19,9 +19,18 @@ impl Scope {
|
|
|
allowed_urls: scope
|
|
|
.0
|
|
|
.iter()
|
|
|
- .map(|url| {
|
|
|
- glob::Pattern::new(url.as_str())
|
|
|
- .unwrap_or_else(|_| panic!("scoped URL is not a valid glob pattern: `{url}`"))
|
|
|
+ .flat_map(|url| {
|
|
|
+ [
|
|
|
+ glob::Pattern::new(url.as_str())
|
|
|
+ .unwrap_or_else(|_| panic!("scoped URL is not a valid glob pattern: `{url}`")),
|
|
|
+ glob::Pattern::new(
|
|
|
+ url
|
|
|
+ .as_str()
|
|
|
+ .strip_suffix('/')
|
|
|
+ .unwrap_or_else(|| url.as_str()),
|
|
|
+ )
|
|
|
+ .unwrap_or_else(|_| panic!("scoped URL is not a valid glob pattern: `{url}`")),
|
|
|
+ ]
|
|
|
})
|
|
|
.collect(),
|
|
|
}
|
|
@@ -81,7 +90,7 @@ mod tests {
|
|
|
let scope = super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://*".parse().unwrap()]));
|
|
|
|
|
|
assert!(scope.is_allowed(&"http://something.else".parse().unwrap()));
|
|
|
- assert!(!scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap()));
|
|
|
+ assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap()));
|
|
|
assert!(!scope.is_allowed(&"https://something.else".parse().unwrap()));
|
|
|
|
|
|
let scope = super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://**".parse().unwrap()]));
|