Skip to content

Commit a673d44

Browse files
princejwesleyaddaleax
authored andcommitted
lib,tools: 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: #9591 Reviewed-By: Teddy Katz <[email protected]>
1 parent 77e145a commit a673d44

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

lib/url.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const protocolPattern = /^([a-z0-9.+-]+:)/i;
4444
const portPattern = /:[0-9]*$/;
4545

4646
// Special case for a simple path URL
47-
const simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/;
47+
const simplePathPattern = /^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/;
4848

4949
const hostnameMaxLen = 255;
5050
// protocols that can allow "unsafe" and "unwise" chars.

tools/doc/html.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function loadGtoc(cb) {
9090
function toID(filename) {
9191
return filename
9292
.replace('.html', '')
93-
.replace(/[^\w\-]/g, '-')
93+
.replace(/[^\w-]/g, '-')
9494
.replace(/-+/g, '-');
9595
}
9696

@@ -284,7 +284,7 @@ function linkJsTypeDocs(text) {
284284
// Handle types, for example the source Markdown might say
285285
// "This argument should be a {Number} or {String}"
286286
for (i = 0; i < parts.length; i += 2) {
287-
typeMatches = parts[i].match(/\{([^\}]+)\}/g);
287+
typeMatches = parts[i].match(/\{([^}]+)\}/g);
288288
if (typeMatches) {
289289
typeMatches.forEach(function(typeMatch) {
290290
parts[i] = parts[i].replace(typeMatch, typeParser.toLink(typeMatch));

tools/doc/json.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function doJSON(input, filename, cb) {
3131
// <!-- type = module -->
3232
// This is for cases where the markdown semantic structure is lacking.
3333
if (type === 'paragraph' || type === 'html') {
34-
var metaExpr = /<!--([^=]+)=([^\-]+)-->\n*/g;
34+
var metaExpr = /<!--([^=]+)=([^-]+)-->\n*/g;
3535
text = text.replace(metaExpr, function(_0, k, v) {
3636
current[k.trim()] = v.trim();
3737
return '';
@@ -371,7 +371,7 @@ function parseListItem(item) {
371371
item.name = 'return';
372372
text = text.replace(retExpr, '');
373373
} else {
374-
var nameExpr = /^['`"]?([^'`": \{]+)['`"]?\s*:?\s*/;
374+
var nameExpr = /^['`"]?([^'`": {]+)['`"]?\s*:?\s*/;
375375
var name = text.match(nameExpr);
376376
if (name) {
377377
item.name = name[1];
@@ -388,7 +388,7 @@ function parseListItem(item) {
388388
}
389389

390390
text = text.trim();
391-
var typeExpr = /^\{([^\}]+)\}/;
391+
var typeExpr = /^\{([^}]+)\}/;
392392
var type = text.match(typeExpr);
393393
if (type) {
394394
item.type = type[1];
@@ -551,7 +551,7 @@ var classMethExpr =
551551
/^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*?$/i;
552552
var methExpr =
553553
/^(?:method:?\s*)?(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*?$/i;
554-
var newExpr = /^new ([A-Z][a-zA-Z]+)\([^\)]*\)\s*?$/;
554+
var newExpr = /^new ([A-Z][a-zA-Z]+)\([^)]*\)\s*?$/;
555555
var paramExpr = /\((.*)\);?$/;
556556

557557
function newSection(tok) {

tools/license2rtf.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function ParagraphParser() {
122122

123123
// Detect separator "lines" within a block. These mark a paragraph break
124124
// and are stripped from the output.
125-
if (/^\s*[=*\-]{5,}\s*$/.test(line)) {
125+
if (/^\s*[=*-]{5,}\s*$/.test(line)) {
126126
flushParagraph();
127127
return;
128128
}
@@ -286,7 +286,7 @@ function RtfGenerator() {
286286

287287
function rtfEscape(string) {
288288
return string
289-
.replace(/[\\\{\}]/g, function(m) {
289+
.replace(/[\\{}]/g, function(m) {
290290
return '\\' + m;
291291
})
292292
.replace(/\t/g, function() {

0 commit comments

Comments
 (0)