Skip to content

Commit

Permalink
feat(perf): hosisted two more literals
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLarkInn committed Jun 30, 2017
1 parent 998c2bb commit f694faa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/RequestShortener.js
Expand Up @@ -8,7 +8,7 @@ const path = require("path");
const NORMALIZE_SLASH_DIRECTION_REGEXP = /\\/g;
const PATH_CHARS_REGEXP = /[-[\]{}()*+?.,\\^$|#\s]/g;
const SEPERATOR_REGEXP = /[\/\\]$/;

const FRONT_OR_BACK_BANG_REGEXP = /^!|!$/;

const normalizeBackSlashDirection = (request) => {
return request.replace(NORMALIZE_SLASH_DIRECTION_REGEXP, "/");
Expand All @@ -22,7 +22,7 @@ const shortenPath = (path) => {
class RequestShortener {
constructor(directory) {
directory = normalizeBackSlashDirection(directory);
if(/[\/\\]$/.test(directory)) directory = directory.substr(0, directory.length - 1);
if(SEPERATOR_REGEXP.test(directory)) directory = directory.substr(0, directory.length - 1);

if(directory) {
const currentDirectoryRegExpString = shortenPath(directory);
Expand Down Expand Up @@ -60,7 +60,7 @@ class RequestShortener {
if(!this.buildinsAsModule && this.buildinsRegExp)
request = request.replace(this.buildinsRegExp, "!(webpack)");
request = request.replace(this.indexJsRegExp, "$1");
return request.replace(/^!|!$/, "");
return request.replace(FRONT_OR_BACK_BANG_REGEXP, "");
}
}

Expand Down

0 comments on commit f694faa

Please sign in to comment.