<commit_before>import { POP } from './Actions';

function createLocation(path='/', state=null, action=POP, key=null) {
  var index = path.indexOf('?');

  var pathname, search;
  if (index !== -1) {
    pathname = path.substring(0, index);
    search = path.substring(index);
  } else {
    pathname = path;
    search = '';
  }

  if (pathname === '')
    pathname = '/';

  return {
    pathname,
    search,
    state,
    action,
    key
  };
}

export default createLocation;<commit_msg>Strip protocol + domain from Location paths<commit_after>import warning from 'warning';
import { POP } from './Actions';

function extractPath(string) {
  var match = string.match(/https?:\/\/[^\/]*/);

  if (match == null)
    return string;

  warning(
    false,
    'Location path must be pathname + query string only, not a fully qualified URL like "%s"',
    string
  );

  return string.substring(match[0].length);
}

function createLocation(path='/', state=null, action=POP, key=null) {
  path = extractPath(path);

  var index = path.indexOf('?');

  var pathname, search;
  if (index !== -1) {
    pathname = path.substring(0, index);
    search = path.substring(index);
  } else {
    pathname = path;
    search = '';
  }

  if (pathname === '')
    pathname = '/';

  return {
    pathname,
    search,
    state,
    action,
    key
  };
}

export default createLocation;
{'fraction_non_alphanumeric': 0.15758896151053015, 'fraction_numerical': 0.0036310820624546117, 'mean_word_length': 2.9371428571428573, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '891137', 'n_tokens_mistral': 456, 'n_tokens_neox': 442, 'n_words': 118}