<commit_before>import queryString from 'query-string';
import pathMatch from 'path-match';
import parseUrl from 'parse-url';

const nativeFetch = window.fetch;

//TODO: Handle response headers
let fakeResponse = function(response = {}) {
  const responseStr = JSON.stringify(response);

  return new Response(responseStr);
};

export const fakeFetch = (serverRoutes) => {
  return (url, options = {}) => {
    const body = options.body || '';
    const method = options.method || 'GET';
    const handlers = serverRoutes[method];

    const pathname = parseUrl(url).pathname;
    const matchesPathname = path => pathMatch()(path)(pathname);
    const route = Object.keys(handlers).find(matchesPathname);

    if (!route) {
      return nativeFetch(url, options);
    }

    const handler = handlers[route];<commit_msg>Use const for fakeResponse function<commit_after>import queryString from 'query-string';
import pathMatch from 'path-match';
import parseUrl from 'parse-url';

const nativeFetch = window.fetch;

//TODO: Handle response headers
const fakeResponse = function(response = {}) {
  const responseStr = JSON.stringify(response);

  return new Response(responseStr);
};

export const fakeFetch = (serverRoutes) => {
  return (url, options = {}) => {
    const body = options.body || '';
    const method = options.method || 'GET';
    const handlers = serverRoutes[method];

    const pathname = parseUrl(url).pathname;
    const matchesPathname = path => pathMatch()(path)(pathname);
    const route = Object.keys(handlers).find(matchesPathname);

    if (!route) {
      return nativeFetch(url, options);
    }

    const handler = handlers[route];
{'fraction_non_alphanumeric': 0.12891566265060242, 'fraction_numerical': 0.0, 'mean_word_length': 4.239747634069401, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3712024', 'n_tokens_mistral': 472, 'n_tokens_neox': 463, 'n_words': 129}