Skip to content

Commit

Permalink
remove useless escape
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed Jul 7, 2018
1 parent fa845a2 commit 56f2f1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ module.exports = {
'array-callback-return': OFF, // 6
'import/no-extraneous-dependencies': OFF, // 7
'no-else-return': OFF, // 9
'no-useless-escape': OFF, // 9
'jsx-a11y/anchor-is-valid': OFF, // 9
'import/order': OFF, // 10
'arrow-body-style': OFF, // 10
Expand Down
20 changes: 9 additions & 11 deletions lib/core/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,37 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const escape = require('escape-string-regexp');

function blogRouting(baseUrl) {
return new RegExp(`^${escape(baseUrl)}blog\/.*html$`);
return new RegExp(`^${baseUrl}blog/.*html$`);
}

function docsRouting(baseUrl) {
return new RegExp(`^${escape(baseUrl)}docs\/.*html$`);
return new RegExp(`^${baseUrl}docs/.*html$`);
}

function dotRouting() {
return /(?!.*html$)^\/.*\.[^\n\/]+$/;
return /(?!.*html$)^\/.*\.[^\n/]+$/;
}

function feedRouting(baseUrl) {
return new RegExp(`^${escape(baseUrl)}blog\/(feed\.xml|atom\.xml)$`);
return new RegExp(`^${baseUrl}blog/(feed.xml|atom.xml)$`);
}

function noExtRouting() {
return /\/[^\.]*\/?$/;
return /\/[^.]*\/?$/;
}

function pageRouting(baseUrl) {
const gr = regex => regex.toString().replace(/(^\/|\/$)/gm, '');
return new RegExp(
`(?!${gr(docsRouting(baseUrl))}|${gr(blogRouting(baseUrl))})^${escape(
baseUrl
)}.*\.html$`
`(?!${gr(docsRouting(baseUrl))}|${gr(
blogRouting(baseUrl)
)})^${baseUrl}.*.html$`
);
}

function sitemapRouting(baseUrl) {
return new RegExp(`^${escape(baseUrl)}sitemap.xml$`);
return new RegExp(`^${baseUrl}sitemap.xml$`);
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion lib/rename-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const CWD = process.cwd();

// escape appropriate characters in a string to be used in a regex
RegExp.escape = function(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
return s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
};

// generate a doc header from metadata
Expand Down

0 comments on commit 56f2f1c

Please sign in to comment.