Skip to content

Commit 7ef16ee

Browse files
committed
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: nodejs#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 4aca347 commit 7ef16ee

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
@@ -1444,13 +1444,13 @@ fs.unwatchFile = function(filename, listener) {
14441444
// Regexp that finds the next portion of a (partial) path
14451445
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
14461446
const nextPartRe = isWindows ?
1447-
/(.*?)(?:[\/\\]+|$)/g :
1448-
/(.*?)(?:[\/]+|$)/g;
1447+
/(.*?)(?:[/\\]+|$)/g :
1448+
/(.*?)(?:[/]+|$)/g;
14491449

14501450
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
14511451
const splitRootRe = isWindows ?
1452-
/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/ :
1453-
/^[\/]*/;
1452+
/^(?:[a-zA-Z]:|[\\/]{2}[^\\/]+[\\/][^\\/]+)?[\\/]*/ :
1453+
/^[/]*/;
14541454

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

lib/url.js

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