Pārlūkot izejas kodu

doc(config): fix http scope example

Lucas Nogueira 3 gadi atpakaļ
vecāks
revīzija
913fb001c6

+ 1 - 1
core/tauri-utils/src/config.rs

@@ -1095,7 +1095,7 @@ impl Allowlist for DialogAllowlistConfig {
 ///
 /// # Examples
 ///
-/// - "https://*": allows all HTTPS urls
+/// - "https://**": allows all HTTPS urls
 /// - "https://*.github.com/tauri-apps/tauri": allows any subdomain of "github.com" with the "tauri-apps/api" path
 /// - "https://myapi.service.com/users/*": allows access to any URLs that begins with "https://myapi.service.com/users/"
 #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)]

+ 6 - 0
core/tauri/src/scope/http.rs

@@ -80,6 +80,12 @@ 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(&"https://something.else".parse().unwrap()));
+
+    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()));
   }
 }

+ 1 - 1
tooling/cli/schema.json

@@ -1041,7 +1041,7 @@
       "additionalProperties": false
     },
     "HttpAllowlistScope": {
-      "description": "HTTP API scope definition. It is a list of URLs that can be accessed by the webview when using the HTTP APIs. The scoped URL is matched against the request URL using a glob pattern.\n\n# Examples\n\n- \"https://*\": allows all HTTPS urls - \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path - \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
+      "description": "HTTP API scope definition. It is a list of URLs that can be accessed by the webview when using the HTTP APIs. The scoped URL is matched against the request URL using a glob pattern.\n\n# Examples\n\n- \"https://**\": allows all HTTPS urls - \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path - \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
       "type": "array",
       "items": {
         "type": "string",