mirror of
https://github.com/BeamMP/BeamMP-Website.git
synced 2026-11-29 17:25:18 +00:00
Include policies, minor fixes and add anonymous analytics
This commit is contained in:
1 parent
74adf15820
commit
01281ebed2
22 files changed
+571
-63
No files matched your search
+3
-3
@@ -31,12 +31,12 @@ export function getLocalizedPath(route, locale = null) {
|
||||
export function switchLocale(newLocale, currentPath) {
|
||||
// Split path from query string
|
||||
const [pathOnly] = currentPath.split('?')
|
||||
|
||||
|
||||
// Remove locale from the beginning: /en/servers -> /servers, /en/ -> /
|
||||
const pathWithoutLocale = pathOnly.replace(/^\/[a-z]{2}(?:\/|$)/, '/')
|
||||
|
||||
|
||||
// Remove trailing slashes and ensure we have the right format
|
||||
const cleanPath = pathWithoutLocale.replace(/\/+/g, '/').replace(/\/$/, '') || ''
|
||||
|
||||
|
||||
return `/${newLocale}${cleanPath}`.replace(/\/+/g, '/')
|
||||
}
|
||||
Reference in new issue
Block a user