PR-URL: https://github.com/nodejs/node/pull/47547 Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
21 lines
579 B
JavaScript
21 lines
579 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const { URL } = require('url');
|
|
const assert = require('assert');
|
|
|
|
let internalBinding;
|
|
try {
|
|
internalBinding = require('internal/test/binding').internalBinding;
|
|
} catch (e) {
|
|
console.log('using `test/parallel/test-whatwg-url-canparse` requires `--expose-internals`');
|
|
throw e;
|
|
}
|
|
|
|
const { canParse } = internalBinding('url');
|
|
|
|
// It should not throw when called without a base string
|
|
assert.strictEqual(URL.canParse('https://example.org'), true);
|
|
assert.strictEqual(canParse('https://example.org'), true);
|