Skip to content

Commit

Permalink
Fix URLSearchParams to_string
Browse files Browse the repository at this point in the history
  • Loading branch information
ryutamago committed Oct 26, 2023
1 parent 9ba44a9 commit a5fc971
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ node_modules/
**/.vitepress/dist

**/dist

.vscode
15 changes: 11 additions & 4 deletions jstz_api/src/url/search_params.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use boa_engine::{
builtins, js_string,
builtins,
builtins::object::Object as GlobalObject,
js_string,
object::{builtins::JsArray, Object},
property::Attribute,
value::TryFromJs,
Expand Down Expand Up @@ -446,9 +448,14 @@ impl UrlSearchParamsClass {
_args: &[JsValue],
context: &mut Context<'_>,
) -> JsResult<JsValue> {
let search_params = UrlSearchParams::try_from_js(this)?;

Ok(search_params.to_string().into_js(context))
UrlSearchParams::try_from_js(this)
.map(|search_params| search_params.to_string().into_js(context))
.or_else(|_| GlobalObject::to_string(this, _args, context))
.or_else(|_| {
Err(JsError::from_native(JsNativeError::typ().with_message(
"Failed to convert `URLSearchParams` into js string",
)))
})
}
}

Expand Down

0 comments on commit a5fc971

Please sign in to comment.