function $876a17d04c37e3f3$var$createPathRewriter(rewriteConfig) {
    let rulesCache;
    if (!$876a17d04c37e3f3$var$isValidRewriteConfig(rewriteConfig)) return;
    if (typeof rewriteConfig === 'function') {
        const customRewriteFn = rewriteConfig;
        return customRewriteFn;
    } else {
        rulesCache = $876a17d04c37e3f3$var$parsePathRewriteRules(rewriteConfig);
        return rewritePath;
    }
    function rewritePath(path) {
        let result = path;
        for (const rule of rulesCache)if (rule.regex.test(path)) {
            result = result.replace(rule.regex, rule.value);
            $876a17d04c37e3f3$var$logger.debug('[HPM] Rewriting path from "%s" to "%s"', path, result);
            break;
        }
        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.
@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 . @param { Object } rewriteConfig @return { Function } Function to rewrite paths ; This function should accept ` path ` ( request . url ) as parameter
function $876a17d04c37e3f3$var$createPathRewriter(rewriteConfig) {
    let rulesCache;
    if (!$876a17d04c37e3f3$var$isValidRewriteConfig(rewriteConfig)) return;
    if (typeof rewriteConfig === 'function') {
        const customRewriteFn = rewriteConfig;
        return customRewriteFn;
    } else {
        rulesCache = $876a17d04c37e3f3$var$parsePathRewriteRules(rewriteConfig);
        return rewritePath;
    }
    function rewritePath(path) {
        let result = path;
        for (const rule of rulesCache)if (rule.regex.test(path)) {
            result = result.replace(rule.regex, rule.value);
            $876a17d04c37e3f3$var$logger.debug('[HPM] Rewriting path from "%s" to "%s"', path, result);
            break;
        }
        return result;
    }
}
function $876a17d04c37e3f3$var$createPathRewriter ( rewriteConfig ) { let rulesCache ; if ( ! $876a17d04c37e3f3$var$isValidRewriteConfig ( rewriteConfig ) ) return ; if ( typeof rewriteConfig === 'function' ) { const customRewriteFn = rewriteConfig ; return customRewriteFn ; } else { rulesCache = $876a17d04c37e3f3$var$parsePathRewriteRules ( rewriteConfig ) ; return rewritePath ; } function rewritePath ( path ) { let result = path ; for ( const rule of rulesCache ) if ( rule . regex . test ( path ) ) { result = result . replace ( rule . regex , rule . value ) ; $876a17d04c37e3f3$var$logger . debug ( '[HPM] Rewriting path from "%s" to "%s"' , path , result ) ; break ; } return result ; } }
Create rewrite function, to cache parsed rewrite rules.
Create rewrite function to cache parsed rewrite rules .