dist/path-rewriter.js
function createPathRewriter(rewriteConfig) {
    let rulesCache;
    if (!isValidRewriteConfig(rewriteConfig)) {
        return;
    }
    if (_.isFunction(rewriteConfig)) {
        const customRewriteFn = rewriteConfig;
        return customRewriteFn;
    }
    else {
        rulesCache = parsePathRewriteRules(rewriteConfig);
        return rewritePath;
    }
    function rewritePath(path) {
        let result = path;
        _.forEach(rulesCache, rule => {
            if (rule.regex.test(path)) {
                result = result.replace(rule.regex, rule.value);
                logger.debug('[HPM] Rewriting path from "%s" to "%s"', path, result);
                return false;
            }
        });
        return result;
    }
}
function createPathRewriter(rewriteConfig) {
    let rulesCache;
    if (!isValidRewriteConfig(rewriteConfig)) {
        return;
    }
    if (_.isFunction(rewriteConfig)) {
        const customRewriteFn = rewriteConfig;
        return customRewriteFn;
    }
    else {
        rulesCache = parsePathRewriteRules(rewriteConfig);
        return rewritePath;
    }
    function rewritePath(path) {
        let result = path;
        _.forEach(rulesCache, rule => {
            if (rule.regex.test(path)) {
                result = result.replace(rule.regex, rule.value);
                logger.debug('[HPM] Rewriting path from "%s" to "%s"', path, result);
                return false;
            }
        });
        return result;
    }
}
function createPathRewriter ( rewriteConfig ) { let rulesCache ; if ( ! isValidRewriteConfig ( rewriteConfig ) ) { return ; } if ( _ . isFunction ( rewriteConfig ) ) { const customRewriteFn = rewriteConfig ; return customRewriteFn ; } else { rulesCache = parsePathRewriteRules ( rewriteConfig ) ; return rewritePath ; } function rewritePath ( path ) { let result = path ; _ . forEach ( rulesCache , rule => { if ( rule . regex . test ( path ) ) { result = result . replace ( rule . regex , rule . value ) ; logger . debug ( '[HPM] Rewriting path from "%s" to "%s"' , path , result ) ; return false ; } } ) ; return result ; } }
Create rewrite function, to cache parsed rewrite rules.

@param {Object} rewriteConfig
@return {Function} Function to rewrite paths; This function should accept `path` (request.url) as parameter
Create rewrite function to cache parsed rewrite rules .