Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib,tools: use internal/url, restrict url in internal code #49590

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ rules:
message: Use `const { structuredClone } = require('internal/structured_clone');` instead of the global.
- name: SubtleCrypto
message: Use `const { SubtleCrypto } = require('internal/crypto/webcrypto');` instead of the global.
no-restricted-modules:
- error
- name: url
message: Require `internal/url` instead of `url`.
# Custom rules in tools/eslint-rules
node-core/avoid-prototype-pollution: error
node-core/lowercase-name-for-primitive: error
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/switches/is_main_thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ rawMethods.resetStdioForTesting = function() {
// Needed by the module loader and generally needed everywhere.
require('fs');
require('util');
require('url');
require('url'); // eslint-disable-line no-restricted-modules

require('internal/modules/cjs/loader');
require('internal/modules/esm/utils');
Expand Down
5 changes: 3 additions & 2 deletions lib/internal/debugger/inspect_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const crypto = require('crypto');
const { ERR_DEBUGGER_ERROR } = require('internal/errors').codes;
const { EventEmitter } = require('events');
const http = require('http');
const URL = require('url');
const { URL } = require('internal/url');

const debuglog = require('internal/util/debuglog').debuglog('inspect');

Expand Down Expand Up @@ -297,7 +297,8 @@ class Client extends EventEmitter {

async _discoverWebsocketPath() {
const { 0: { webSocketDebuggerUrl } } = await this._fetchJSON('/json');
return URL.parse(webSocketDebuggerUrl).path;
const { pathname, search } = new URL(webSocketDebuggerUrl);
return `${pathname}${search}`;
anonrig marked this conversation as resolved.
Show resolved Hide resolved
LiviaMedeiros marked this conversation as resolved.
Show resolved Hide resolved
}

_connectWebsocket(urlPath) {
Expand Down