<commit_before>import React, { useEffect } from 'react';
import Helmet from 'react-helmet';
import { connect } from 'react-redux';
import _ from 'lodash';
import { formatPattern } from 'react-router/es/PatternUtils';

import {
  createPost,
  resetPostCreateForm,
  expandSendTo,
  getUserInfo,
} from '../redux/action-creators';
import { getCurrentRouteName } from '../utils';
import config from '../config';
import { joinPostData, postActions, userActions, canAcceptDirects } from './select-utils';
import FeedOptionsSwitch from './feed-options-switch';
import Breadcrumbs from './breadcrumbs';
import ErrorBoundary from './error-boundary';
import UserProfile from './user-profile';
import UserFeed from './user-feed';

const UserHandler = (props) => {
  // Redirect to canonical username in URI (/uSErNAme/likes?offset=30 → /username/likes?offset=30)
  useEffect(() => {
    if (
      props.viewUser.username &&
      props.routeParams.userName &&
      props.viewUser.username !== props.routeParams.userName
    ) {
      const newPath = formatPattern(props.route.path, {
        ...props.routeParams,
        userName: props.viewUser.username,
      });
      props.router.replace(newPath + props.location.search);
    }
  }, [
    props.location.search,
    props.route.path,
    props.routeParams,
    props.routeParams.userName,
    props.router,
    props.viewUser.username,
  ]);

  return (
    <div className="box">
      <ErrorBoundary><commit_msg>Only check username correctness after the feed load<commit_after>import React, { useEffect } from 'react';
import Helmet from 'react-helmet';
import { connect } from 'react-redux';
import _ from 'lodash';
import { formatPattern } from 'react-router/es/PatternUtils';

import {
  createPost,
  resetPostCreateForm,
  expandSendTo,
  getUserInfo,
} from '../redux/action-creators';
import { getCurrentRouteName } from '../utils';
import config from '../config';
import { joinPostData, postActions, userActions, canAcceptDirects } from './select-utils';
import FeedOptionsSwitch from './feed-options-switch';
import Breadcrumbs from './breadcrumbs';
import ErrorBoundary from './error-boundary';
import UserProfile from './user-profile';
import UserFeed from './user-feed';

const UserHandler = (props) => {
  // Redirect to canonical username in URI (/uSErNAme/likes?offset=30 → /username/likes?offset=30)
  useEffect(() => {
    if (
      !props.viewUser.isLoading &&
      props.viewUser.username &&
      props.routeParams.userName &&
      props.viewUser.username !== props.routeParams.userName
    ) {
      const newPath = formatPattern(props.route.path, {
        ...props.routeParams,
        userName: props.viewUser.username,
      });
      props.router.replace(newPath + props.location.search);
    }
  }, [
    props.location.search,
    props.route.path,
    props.routeParams,
    props.routeParams.userName,
    props.router,
    props.viewUser.isLoading,
    props.viewUser.username,
  ]);

  return (
    <div className="box">
      <ErrorBoundary>
{'fraction_non_alphanumeric': 0.1341261975553353, 'fraction_numerical': 0.002642880740006607, 'mean_word_length': 3.5533834586466164, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '7356263', 'n_tokens_mistral': 911, 'n_tokens_neox': 897, 'n_words': 204}