<commit_before>import React from 'react';
import { Routes, Route, useParams, Navigate } from 'react-router-dom';
import { Error } from 'app/components';

const mainTitle = 'Vespa Console';

function TitledRoute({ element, title, default: isDefault, ...props }) {
  const params = useParams();
  const clone = React.cloneElement(element, Object.assign(props, params));
  if (title != null) {
    const titleStr = typeof title === 'function' ? title(params) : title;
    document.title = titleStr.endsWith(mainTitle)
      ? titleStr
      : `${titleStr} - ${mainTitle}`;
  } else if (isDefault) {
    // Reset the title if title is not set and this is a default router
    document.title = mainTitle;
  }

  return clone;
}

export function Router({ children }) {
  // If there is only one route then this comes as an object.
  if (!Array.isArray(children)) children = [children];
  children = children.filter(({ props }) => props.enabled ?? true);

  if (!children.some((child) => child.props.default))
    children.push(<Error code={404} default />);

  return (
    <Routes>
      {children.map(({ props, ...element }, i) => (
        <Route
          key={`${i}-${props.path}`}
          path={props.default ? '*' : props.path}
          element={
            element.type === Redirect ? (
              Object.assign({ props }, element)
            ) : (
              <TitledRoute element={element} {...props} />
            )
          }
        />
      ))}
    </Routes>
  );
}

export function Redirect({ to, replace }) {
  return <Navigate {...{ to, replace }} />;
}
<commit_msg>Rename title<commit_after>import React from 'react';
import { Routes, Route, useParams, Navigate } from 'react-router-dom';
import { Error } from 'app/components';

const mainTitle = 'Vespa App';

function TitledRoute({ element, title, default: isDefault, ...props }) {
  const params = useParams();
  const clone = React.cloneElement(element, Object.assign(props, params));
  if (title != null) {
    const titleStr = typeof title === 'function' ? title(params) : title;
    document.title = titleStr.endsWith(mainTitle)
      ? titleStr
      : `${titleStr} - ${mainTitle}`;
  } else if (isDefault) {
    // Reset the title if title is not set and this is a default router
    document.title = mainTitle;
  }

  return clone;
}

export function Router({ children }) {
  // If there is only one route then this comes as an object.
  if (!Array.isArray(children)) children = [children];
  children = children.filter(({ props }) => props.enabled ?? true);

  if (!children.some((child) => child.props.default))
    children.push(<Error code={404} default />);

  return (
    <Routes>
      {children.map(({ props, ...element }, i) => (
        <Route
          key={`${i}-${props.path}`}
          path={props.default ? '*' : props.path}
          element={
            element.type === Redirect ? (
              Object.assign({ props }, element)
            ) : (
              <TitledRoute element={element} {...props} />
            )
          }
        />
      ))}
    </Routes>
  );
}

export function Redirect({ to, replace }) {
  return <Navigate {...{ to, replace }} />;
}

{'fraction_non_alphanumeric': 0.1594705326189726, 'fraction_numerical': 0.0018909549322407816, 'mean_word_length': 2.5823927765237022, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, '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': '350491', 'n_tokens_mistral': 943, 'n_tokens_neox': 936, 'n_words': 261}