Skip to content

Commit d6d2410

Browse files
committed
url: runtime deprecate url.parse
1 parent 291d90a commit d6d2410

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

doc/api/deprecations.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3441,6 +3441,10 @@ Node-API callbacks.
34413441

34423442
<!-- YAML
34433443
changes:
3444+
- version:
3445+
- REPLACEME
3446+
pr-url: https://github.com/nodejs/node/pull/55017
3447+
description: Application deprecation.
34443448
- version:
34453449
- v19.9.0
34463450
- v18.17.0
@@ -3453,7 +3457,7 @@ changes:
34533457
description: Documentation-only deprecation.
34543458
-->
34553459

3456-
Type: Documentation-only (supports [`--pending-deprecation`][])
3460+
Type: Application (non-`node_modules` code only)
34573461

34583462
[`url.parse()`][] behavior is not standardized and prone to errors that
34593463
have security implications. Use the [WHATWG URL API][] instead. CVEs are not

lib/url.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const {
4646
// This ensures setURLConstructor() is called before the native
4747
// URL::ToObject() method is used.
4848
const { spliceOne } = require('internal/util');
49+
const { isInsideNodeModules } = internalBinding('util');
4950

5051
// WHATWG URL implementation provided by internal/url
5152
const {
@@ -63,8 +64,6 @@ const {
6364

6465
const bindingUrl = internalBinding('url');
6566

66-
const { getOptionValue } = require('internal/options');
67-
6867
// Original url.parse() API
6968

7069
function Url() {
@@ -125,7 +124,7 @@ const {
125124
let urlParseWarned = false;
126125

127126
function urlParse(url, parseQueryString, slashesDenoteHost) {
128-
if (!urlParseWarned && getOptionValue('--pending-deprecation')) {
127+
if (!urlParseWarned && !isInsideNodeModules()) {
129128
urlParseWarned = true;
130129
process.emitWarning(
131130
'`url.parse()` behavior is not standardized and prone to ' +

typings/internalBinding/util.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ export interface UtilBinding {
4545
guessHandleType(fd: number): 'TCP' | 'TTY' | 'UDP' | 'FILE' | 'PIPE' | 'UNKNOWN';
4646
parseEnv(content: string): Record<string, string>;
4747
styleText(format: Array<string> | string, text: string): string;
48+
isInsideNodeModules(): boolean;
4849
}

0 commit comments

Comments
 (0)