node/test/parallel/test-url-is-url.js
Zhuo Zhang d7ed3a4abc url: fix isURL detection by checking path
Fixes: https://github.com/nodejs/node/issues/48921
PR-URL: https://github.com/nodejs/node/pull/48928
Fixes: https://github.com/getsentry/sentry-javascript/issues/8552
Fixes: https://github.com/request/request/issues/3458
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
2023-07-29 23:44:14 +05:30

16 lines
427 B
JavaScript

// Flags: --expose-internals
'use strict';
require('../common');
const { URL, parse } = require('url');
const assert = require('assert');
const { isURL } = require('internal/url');
assert.strictEqual(isURL(new URL('https://www.nodejs.org')), true);
assert.strictEqual(isURL(parse('https://www.nodejs.org')), false);
assert.strictEqual(isURL({
href: 'https://www.nodejs.org',
protocol: 'https:',
path: '/',
}), false);