diff --git a/src/node_url.cc b/src/node_url.cc index 75aaf468f508f2..fcbd45e02c5bdf 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -444,7 +444,9 @@ void BindingData::Update(const FunctionCallbackInfo& args) { std::string_view new_value_view = new_value.ToStringView(); auto out = ada::parse(input.ToStringView()); - CHECK(out); + if (!out) { + return args.GetReturnValue().Set(false); + } bool result{true}; diff --git a/test/parallel/test-whatwg-url-custom-setters.js b/test/parallel/test-whatwg-url-custom-setters.js index b98bf5d8d3b393..a6f4ee5c729f76 100644 --- a/test/parallel/test-whatwg-url-custom-setters.js +++ b/test/parallel/test-whatwg-url-custom-setters.js @@ -39,6 +39,27 @@ const additionalTestCases = } } +test(function() { + const url = new URL('http:\u{1F600}xn-'); + const href = url.href; + const setters = { + hostname: 'example.com', + host: 'example.com:8080', + protocol: 'https:', + pathname: '/path', + search: '?search', + hash: '#hash', + port: '8080', + username: 'username', + password: 'password', + }; + + for (const [property, value] of Object.entries(setters)) { + url[property] = value; + assert_equals(url.href, href, `Setting ${property} leaves the URL unchanged`); + } +}, 'URL: setting properties with an unparsable serialized URL'); + { const url = new URL('http://example.com/'); const obj = {