dist/plugin.js
/** Converts a path string into a regular expression which matches that path with some looseness
 * around slashes and whitespace. */
Converts a path string into a regular expression which matches that path with some looseness
around slashes and whitespace.
Converts a path string into a regular expression which matches that path with some looseness around slashes and whitespace .
function createPathRewriter(fromPath, toPath) {
    const normalisedPathString = fromPath
        .replace(/^[/\\]/, "")
        .replace(/[\[\]]/g, "\\$&")
        .replace(/[/\\](?![\[\]])/g, "[/\\\\]")
        .replace(/[$^*+?.()|{}]/g, "\\$&");
    const regexStr = `^\\s*[/\\\\]?` + normalisedPathString + "\\s*$";
    const regex = new RegExp(regexStr);
    regex.replace = toPath ? toPath : false;
    return regex;
}
function createPathRewriter ( fromPath , toPath ) { const normalisedPathString = fromPath . replace ( / ^[/\\] / , "" ) . replace ( / [\[\]] / g , "\\$&" ) . replace ( / [/\\](?![\[\]]) / g , "[/\\\\]" ) . replace ( / [$^*+?.()|{}] / g , "\\$&" ) ; const regexStr = ` \\ \\ \\ ` + normalisedPathString + "\\s*$" ; const regex = new RegExp ( regexStr ) ; regex . replace = toPath ? toPath : false ; return regex ; }
Converts a path string into a regular expression which matches that path with some looseness
 around slashes and whitespace.
Converts a path string into a regular expression which matches that path with some looseness around slashes and whitespace .
// Remove any existing leading slash. // Escape existing bracket regex chars. Actual character sets will be added soon, so brackets // in the original string need to be escaped first. // Convert slashes so they match either forward or backwards, unless they're escaping the // brackets in the previous step. // Escape all other characters with special meaning in regular expressions. // Ignore leading/trailing whitespace, and allow either slash or no slash at the start.