{"size": 446, "ext": "js", "max_stars_repo_path": "docs/scripts/languageHelpers.js", "max_stars_repo_name": "LeticiaMachadoo/rsuite", "max_stars_repo_stars_event_min_datetime": "2020-05-21T13:41:17.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-03T13:14:37.000Z", "max_issues_repo_path": "docs/scripts/languageHelpers.js", "max_issues_repo_name": "LeticiaMachadoo/rsuite", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/scripts/languageHelpers.js", "max_forks_repo_name": "LeticiaMachadoo/rsuite", "max_forks_repo_forks_event_min_datetime": "2020-04-16T03:07:22.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-16T03:07:22.000Z"}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 21.2380952381, "max_line_length": 94, "alphanum_fraction": 0.6322869955}
const LANGUAGES = ['en', 'zh'];

function pathnameToLanguage(pathname) {
  const userLanguage = pathname.substring(1, 3);

  if (LANGUAGES.indexOf(userLanguage) !== -1 && pathname.indexOf(`/${userLanguage}/`) === 0) {
    return {
      userLanguage,
      canonical: userLanguage === 'zh' ? pathname : pathname.substring(3)
    };
  }

  return {
    userLanguage: 'zh',
    canonical: pathname
  };
}
module.exports = {
  pathnameToLanguage
};
