2021-08-02 06:40:02 +00:00
|
|
|
export function getLanguageFromURL(pathname: string) {
|
2021-08-02 06:48:53 +00:00
|
|
|
const langCodeMatch = pathname.match(/\/([a-z]{2}-?[A-Z]{0,2})\//);
|
2021-08-02 06:38:50 +00:00
|
|
|
return langCodeMatch ? langCodeMatch[1] : 'en';
|
2021-08-02 06:40:02 +00:00
|
|
|
}
|
2021-09-05 00:55:55 +00:00
|
|
|
|
|
|
|
/** Remove \ and / from beginning of string */
|
|
|
|
export function removeLeadingSlash(path: string) {
|
|
|
|
return path.replace(/^[/\\]+/, '');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Remove \ and / from end of string */
|
|
|
|
export function removeTrailingSlash(path: string) {
|
|
|
|
return path.replace(/[/\\]+$/, '');
|
|
|
|
}
|