mirror of
https://github.com/tauri-apps/tauri-plugin-http.git
synced 2026-01-31 00:45:17 +01:00
fix(shell): fix schema requiring sidecar property even though it is optional (#1839)
* fix(shell): fix schema requiring `sidecar` property even though it is optional * fix clippy * make `cmd` and `sidecar` exclusive * make args optional * cleanup --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app> Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/11126148459 Co-authored-by: lucasfernog <lucasfernog@users.noreply.github.com>
This commit is contained in:
27
build.rs
27
build.rs
@@ -47,23 +47,16 @@ enum HttpScopeEntry {
|
||||
},
|
||||
}
|
||||
|
||||
// Ensure scope entry is kept up to date
|
||||
impl From<HttpScopeEntry> for scope::Entry {
|
||||
fn from(value: HttpScopeEntry) -> Self {
|
||||
let url = match value {
|
||||
HttpScopeEntry::Value(url) => url,
|
||||
HttpScopeEntry::Object { url } => url,
|
||||
};
|
||||
|
||||
scope::Entry {
|
||||
url: urlpattern::UrlPattern::parse(
|
||||
urlpattern::UrlPatternInit::parse_constructor_string::<regex::Regex>(&url, None)
|
||||
.unwrap(),
|
||||
Default::default(),
|
||||
)
|
||||
.unwrap(),
|
||||
}
|
||||
}
|
||||
// Ensure `HttpScopeEntry` and `scope::EntryRaw` is kept in sync
|
||||
fn _f() {
|
||||
match scope::EntryRaw::Value(String::new()) {
|
||||
scope::EntryRaw::Value(url) => HttpScopeEntry::Value(url),
|
||||
scope::EntryRaw::Object { url } => HttpScopeEntry::Object { url },
|
||||
};
|
||||
match HttpScopeEntry::Value(String::new()) {
|
||||
HttpScopeEntry::Value(url) => scope::EntryRaw::Value(url),
|
||||
HttpScopeEntry::Object { url } => scope::EntryRaw::Object { url },
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
14
src/scope.rs
14
src/scope.rs
@@ -33,18 +33,18 @@ fn parse_url_pattern(s: &str) -> Result<UrlPattern, urlpattern::quirks::Error> {
|
||||
UrlPattern::parse(init, Default::default())
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub(crate) enum EntryRaw {
|
||||
Value(String),
|
||||
Object { url: String },
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for Entry {
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
#[derive(Deserialize)]
|
||||
#[serde(untagged)]
|
||||
enum EntryRaw {
|
||||
Value(String),
|
||||
Object { url: String },
|
||||
}
|
||||
|
||||
EntryRaw::deserialize(deserializer).and_then(|raw| {
|
||||
let url = match raw {
|
||||
EntryRaw::Value(url) => url,
|
||||
|
||||
Reference in New Issue
Block a user