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

url: refactor to use more primordials #45966

Merged
merged 11 commits into from
Jan 22, 2023
Prev Previous commit
Next Next commit
do not harden in case that helps
  • Loading branch information
aduh95 committed Dec 26, 2022
commit b2ab16ceabda2f5631c7b04c678d47cb1733a796
13 changes: 6 additions & 7 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const {
SymbolIterator,
SymbolToStringTag,
decodeURIComponent,
hardenRegExp,
} = primordials;

const { inspect } = require('internal/util/inspect');
Expand Down Expand Up @@ -117,7 +116,7 @@ const {
revokeDataObject,
} = internalBinding('blob');

const FORWARD_SLASH = hardenRegExp(/\//g);
const FORWARD_SLASH = /\//g;

const context = Symbol('context');
const cannotBeBase = Symbol('cannot-be-base');
Expand Down Expand Up @@ -1505,11 +1504,11 @@ function fileURLToPath(path) {
// - CR: The carriage return character is also stripped out by the `pathname`
// setter.
// - TAB: The tab character is also stripped out by the `pathname` setter.
const percentRegEx = hardenRegExp(/%/g);
const backslashRegEx = hardenRegExp(/\\/g);
const newlineRegEx = hardenRegExp(/\n/g);
const carriageReturnRegEx = hardenRegExp(/\r/g);
const tabRegEx = hardenRegExp(/\t/g);
const percentRegEx = /%/g;
const backslashRegEx = /\\/g;
const newlineRegEx = /\n/g;
const carriageReturnRegEx = /\r/g;
const tabRegEx = /\t/g;

function encodePathChars(filepath) {
if (StringPrototypeIncludes(filepath, '%'))
Expand Down