diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2021-04-20 14:47:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-20 14:47:22 +0200 |
commit | 9e6cd91014ac4a0d34556b0d09cbe25e4e0930c6 (patch) | |
tree | 4523790510a17676c987039feb03f208a258dc16 /op_crates/url/lib.rs | |
parent | 115197ffb06aad2a3045e8478980ab911b5a5eeb (diff) |
chore: align fetch to spec (#10203)
This commit aligns the `fetch` API and the `Request` / `Response`
classes belonging to it to the spec. This commit enables all the
relevant `fetch` WPT tests. Spec compliance is now at around 90%.
Performance is essentially identical now (within 1% of 1.9.0).
Diffstat (limited to 'op_crates/url/lib.rs')
-rw-r--r-- | op_crates/url/lib.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/op_crates/url/lib.rs b/op_crates/url/lib.rs index f216768c3..04663e411 100644 --- a/op_crates/url/lib.rs +++ b/op_crates/url/lib.rs @@ -118,14 +118,21 @@ pub fn op_url_parse( pub fn op_url_parse_search_params( _state: &mut deno_core::OpState, - args: String, - _zero_copy: Option<ZeroCopyBuf>, + args: Option<String>, + zero_copy: Option<ZeroCopyBuf>, ) -> Result<Vec<(String, String)>, AnyError> { - let search_params: Vec<_> = form_urlencoded::parse(args.as_bytes()) - .into_iter() - .map(|(k, v)| (k.as_ref().to_owned(), v.as_ref().to_owned())) - .collect(); - Ok(search_params) + let params = match (args, zero_copy) { + (None, Some(zero_copy)) => form_urlencoded::parse(&zero_copy) + .into_iter() + .map(|(k, v)| (k.as_ref().to_owned(), v.as_ref().to_owned())) + .collect(), + (Some(args), None) => form_urlencoded::parse(args.as_bytes()) + .into_iter() + .map(|(k, v)| (k.as_ref().to_owned(), v.as_ref().to_owned())) + .collect(), + _ => return Err(type_error("invalid parameters")), + }; + Ok(params) } pub fn op_url_stringify_search_params( |