From 57b3c3f7d1ffe7df6c3a07278ca7c6954140d2a0 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Fri, 12 May 2023 20:19:06 +0000 Subject: [PATCH] feat: use tauri `next` branch, fix tests, MSRV 1.65 (#354) Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/4962685314 Co-authored-by: lucasfernog --- Cargo.toml | 21 +++++++-------------- README.md | 2 +- src/commands/mod.rs | 5 +---- src/scope.rs | 24 ++++++++++-------------- 4 files changed, 19 insertions(+), 33 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ef5741c..3272ad3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,22 +1,15 @@ [package] name = "tauri-plugin-http" version = "0.0.0" -edition = "2021" -#edition.workspace = true -#authors.workspace = true -#license.workspace = true +edition.workspace = true +authors.workspace = true +license.workspace = true [dependencies] -#serde.workspace = true -#serde_json.workspace = true -#tauri.workspace = true -#log.workspace = true -#thiserror.workspace = true -tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next" } -serde = "1" -serde_json = "1" -thiserror = "1" - +serde.workspace = true +serde_json.workspace = true +tauri.workspace = true +thiserror.workspace = true glob = "0.3" rand = "0.8" bytes = { version = "1", features = [ "serde" ] } diff --git a/README.md b/README.md index 0bace1a..de55e8d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## Install -_This plugin requires a Rust version of at least **1.64**_ +_This plugin requires a Rust version of at least **1.65**_ There are three general methods of installation that we can recommend. diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 24acf09..f38d6ea 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,9 +1,6 @@ use tauri::{path::SafePathBuf, AppHandle, Runtime, State}; -use crate::{ - - ClientId, Http, -}; +use crate::{ClientId, Http}; mod client; use client::{Body, ClientBuilder, FilePart, FormPart, HttpRequestBuilder, ResponseData}; diff --git a/src/scope.rs b/src/scope.rs index 115ba78..241c281 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -38,12 +38,12 @@ impl Scope { #[cfg(test)] mod tests { - use tauri_utils::config::HttpAllowlistScope; + use tauri::utils::config::HttpAllowlistScope; #[test] fn is_allowed() { // plain URL - let scope = super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://localhost:8080" + let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://localhost:8080" .parse() .unwrap()])); assert!(scope.is_allowed(&"http://localhost:8080".parse().unwrap())); @@ -56,10 +56,9 @@ mod tests { assert!(!scope.is_allowed(&"http://local:8080".parse().unwrap())); // URL with fixed path - let scope = - super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://localhost:8080/file.png" - .parse() - .unwrap()])); + let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://localhost:8080/file.png" + .parse() + .unwrap()])); assert!(scope.is_allowed(&"http://localhost:8080/file.png".parse().unwrap())); @@ -68,25 +67,22 @@ mod tests { assert!(!scope.is_allowed(&"http://localhost:8080/file.png/other.jpg".parse().unwrap())); // URL with glob pattern - let scope = - super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://localhost:8080/*.png" - .parse() - .unwrap()])); + let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://localhost:8080/*.png" + .parse() + .unwrap()])); assert!(scope.is_allowed(&"http://localhost:8080/file.png".parse().unwrap())); assert!(scope.is_allowed(&"http://localhost:8080/assets/file.png".parse().unwrap())); assert!(!scope.is_allowed(&"http://localhost:8080/file.jpeg".parse().unwrap())); - let scope = - super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://*".parse().unwrap()])); + let scope = super::Scope::new(&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()])); + let scope = super::Scope::new(&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()));