<commit_before>// @ts-check
const { coalesceToTerminals, matcherForTerminal } = require('ng-pwa-tools/lib/ls-routes/lib');

/**
 * Convert routes json file to SW config
 * @param {String} index
 * @param {Array} routes
 * @param {String=} baseUrl
 */
function genRoutingManifest(index, routes, baseUrl = '/') {
  if (baseUrl.endsWith('/')) {
    baseUrl = baseUrl.substr(0, baseUrl.length - 1);
  }

  const routesConfig = coalesceToTerminals(flattenRoutes(routes))
    .map(terminal => matcherForTerminal(terminal, baseUrl))
    .reduce(
    (routes, matcher) => (routes[matcher.pattern] = { prefix: true }, routes),
    {}
    );

  return ({ index: index, routes: routesConfig });
}

exports.genRoutingManifest = genRoutingManifest;

/**
 * @param {Array} routes
 * @param {String=} routes<commit_msg>prefix to false fix offline in sw<commit_after>// @ts-check
const { coalesceToTerminals, matcherForTerminal } = require('ng-pwa-tools/lib/ls-routes/lib');

/**
 * Convert routes json file to SW config
 * @param {String} index
 * @param {Array} routes
 * @param {String=} baseUrl
 */
function genRoutingManifest(index, routes, baseUrl = '/') {
  if (baseUrl.endsWith('/')) {
    baseUrl = baseUrl.substr(0, baseUrl.length - 1);
  }

  const routesConfig = coalesceToTerminals(flattenRoutes(routes))
    .map(terminal => matcherForTerminal(terminal, baseUrl))
    .reduce(
    (routes, matcher) => (routes[matcher.pattern] = { prefix: false }, routes),
    {}
    );

  return ({ index: index, routes: routesConfig });
}

exports.genRoutingManifest = genRoutingManifest;

/**
 * @param {Array} routes
 * @param {String=} routes
{'fraction_non_alphanumeric': 0.15592387968078575, 'fraction_numerical': 0.0024554941682013503, 'mean_word_length': 4.174603174603175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6844857', 'n_tokens_mistral': 534, 'n_tokens_neox': 538, 'n_words': 121}