Skip to content

Commit 88ed8dd

Browse files
TrottMylesBorins
authored andcommitted
lib,test: remove unneeded escaping of /
The `/` character does not need to be escaped when occurring inside a character class in a regular expression. Remove such instances of escaping in the code base. PR-URL: #9485 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Teddy Katz <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
1 parent c350268 commit 88ed8dd

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

lib/fs.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1566,13 +1566,13 @@ fs.unwatchFile = function(filename, listener) {
15661566
// Regexp that finds the next portion of a (partial) path
15671567
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
15681568
const nextPartRe = isWindows ?
1569-
/(.*?)(?:[\/\\]+|$)/g :
1570-
/(.*?)(?:[\/]+|$)/g;
1569+
/(.*?)(?:[/\\]+|$)/g :
1570+
/(.*?)(?:[/]+|$)/g;
15711571

15721572
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
15731573
const splitRootRe = isWindows ?
1574-
/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/ :
1575-
/^[\/]*/;
1574+
/^(?:[a-zA-Z]:|[\\/]{2}[^\\/]+[\\/][^\\/]+)?[\\/]*/ :
1575+
/^[/]*/;
15761576

15771577
function encodeRealpathResult(result, options, err) {
15781578
if (!options || !options.encoding || options.encoding === 'utf8' || err)

lib/url.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
200200
// user@server is *always* interpreted as a hostname, and url
201201
// resolution will treat //foo/bar as host=foo,path=bar because that's
202202
// how the browser resolves relative URLs.
203-
if (slashesDenoteHost || proto || /^\/\/[^@\/]+@[^@\/]+/.test(rest)) {
203+
if (slashesDenoteHost || proto || /^\/\/[^@/]+@[^@/]+/.test(rest)) {
204204
var slashes = rest.charCodeAt(0) === 47/*/*/ &&
205205
rest.charCodeAt(1) === 47/*/*/;
206206
if (slashes && !(proto && hostlessProtocol[proto])) {

test/debugger/test-debugger-repl-break-in-module.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repl.addTest('sb(")^$*+?}{|][(.js\\\\", 1)', [
2020

2121
// continue - the breakpoint should be triggered
2222
repl.addTest('c', [
23-
/break in .*[\\\/]mod\.js:2/,
23+
/break in .*[\\/]mod\.js:2/,
2424
/1/, /2/, /3/, /4/
2525
]);
2626

@@ -42,7 +42,7 @@ repl.addTest('restart', [].concat(
4242

4343
// continue - the breakpoint should be triggered
4444
repl.addTest('c', [
45-
/break in .*[\\\/]mod\.js:2/,
45+
/break in .*[\\/]mod\.js:2/,
4646
/1/, /2/, /3/, /4/
4747
]);
4848

@@ -53,7 +53,7 @@ repl.addTest('cb("mod.js", 2)', [
5353
]);
5454

5555
repl.addTest('c', [
56-
/break in .*[\\\/]main\.js:4/,
56+
/break in .*[\\/]main\.js:4/,
5757
/2/, /3/, /4/, /5/, /6/
5858
]);
5959

test/parallel/test-require-json.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var assert = require('assert');
66
try {
77
require(path.join(common.fixturesDir, 'invalid.json'));
88
} catch (err) {
9-
var re = /test[\/\\]fixtures[\/\\]invalid.json: Unexpected string/;
9+
var re = /test[/\\]fixtures[/\\]invalid.json: Unexpected string/;
1010
var i = err.message.match(re);
1111
assert.notStrictEqual(null, i, 'require() json error should include path');
1212
}

0 commit comments

Comments
 (0)