diff --git a/src/node_url.cc b/src/node_url.cc index 463de5f268ee95..1cb0a5fd210f36 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -115,7 +115,7 @@ void BindingData::DomainToUnicode(const FunctionCallbackInfo& args) { // TODO(@anonrig): Add V8 Fast API for CanParse method void BindingData::CanParse(const FunctionCallbackInfo& args) { - CHECK_GE(args.Length(), 2); + CHECK_GE(args.Length(), 1); CHECK(args[0]->IsString()); // input // args[1] // base url diff --git a/test/parallel/test-whatwg-url-canparse.js b/test/parallel/test-whatwg-url-canparse.js new file mode 100644 index 00000000000000..8f8ada132b5ede --- /dev/null +++ b/test/parallel/test-whatwg-url-canparse.js @@ -0,0 +1,9 @@ +'use strict'; + +require('../common'); + +const { URL } = require('url'); +const assert = require('assert'); + +// It should not throw when called without a base string +assert.strictEqual(URL.canParse('https://example.org'), true);