mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
34e03cf912
* Revert "[ci] yarn format"
This reverts commit 93489946cc
.
* chore: ignore vendor
10 lines
362 B
TypeScript
10 lines
362 B
TypeScript
import { KNOWN_LANGUAGES } from './config';
|
|
|
|
export { KNOWN_LANGUAGES }
|
|
export const KNOWN_LANGUAGE_CODES = Object.values(KNOWN_LANGUAGES);
|
|
export const langPathRegex = /\/([a-z]{2}-?[A-Z]{0,2})\//;
|
|
|
|
export function getLanguageFromURL(pathname: string) {
|
|
const langCodeMatch = pathname.match(langPathRegex);
|
|
return langCodeMatch ? langCodeMatch[1] : 'en';
|
|
}
|