<commit_before>angular
.module('fake')

.factory('FakeUriParser', ['FakeConfig', function(FakeConfig) {
  var {PATHS: rootPaths} = FakeConfig,
      patterns = {
        param: /\{[a-z0-9\-\_]+\}/ig,
        root: /^(\$[a-z0-9\-\_]+)/i
      };

  return function(path) {
    var paramMatches = (path.toString().match(patterns.param) || []),
        rootNameMatch = (path.toString().match(patterns.root)),
        rootName = rootNameMatch ? rootNameMatch[0] : '',
        rootPath = rootPaths[rootName] || '',

        escape = (string) => (string || '').replace(/([\/\:\.])/g, '\\$1');

    this.params = paramMatches.map((param) => param.replace(/[\{\}]/g, ''));

    this.pattern = new RegExp(
      '^' +
      escape(rootPath) +
      escape(path)
        .replace(patterns.root, '')
        .replace(patterns.param, '([a-z0-9\\-\\_]+)') +
      '(\\?.*)?$');

    this.getPathParams = function(uri) {
      var paramValues = uri
            .toString()
            .match(this.pattern)
            .filter((match, index) => index > 0 && index <= this.params.length);

      return this
        .params
        .reduce((paramsObject, paramName, index) => {
          paramsObject[paramName] = decodeURI(paramValues[index]);
          return paramsObject;
        }, {});
    };

    this.getQueryParams = function(uri) {
      return ((uri.toString().match(/\?.*/) || [])[0] || '')<commit_msg>Add match safe fallback<commit_after>angular
.module('fake')

.factory('FakeUriParser', ['FakeConfig', function(FakeConfig) {
  var {PATHS: rootPaths} = FakeConfig,
      patterns = {
        param: /\{[a-z0-9\-\_]+\}/ig,
        root: /^(\$[a-z0-9\-\_]+)/i
      };

  return function(path) {
    var paramMatches = (path.toString().match(patterns.param) || []),
        rootNameMatch = (path.toString().match(patterns.root)),
        rootName = rootNameMatch ? rootNameMatch[0] : '',
        rootPath = rootPaths[rootName] || '',

        escape = (string) => (string || '').replace(/([\/\:\.])/g, '\\$1');

    this.params = paramMatches.map((param) => param.replace(/[\{\}]/g, ''));

    this.pattern = new RegExp(
      '^' +
      escape(rootPath) +
      escape(path)
        .replace(patterns.root, '')
        .replace(patterns.param, '([a-z0-9\\-\\_]+)') +
      '(\\?.*)?$');

    this.getPathParams = function(uri) {
      var paramValues = (uri.toString().match(this.pattern) || [])
            .filter((match, index) => index > 0 && index <= this.params.length);

      return this
        .params
        .reduce((paramsObject, paramName, index) => {
          paramsObject[paramName] = decodeURI(paramValues[index]);
          return paramsObject;
        }, {});
    };

    this.getQueryParams = function(uri) {
      return ((uri.toString().match(/\?.*/) || [])[0] || '')
{'fraction_non_alphanumeric': 0.2187948350071736, 'fraction_numerical': 0.007173601147776184, 'mean_word_length': 2.3683574879227054, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '3847722', 'n_tokens_mistral': 930, 'n_tokens_neox': 907, 'n_words': 141}