Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
s00d committed Apr 28, 2024
1 parent eed7b0f commit 334a4ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function localizeRoutes(routes: NuxtPage[], options: LocalizeRoutesParams

let localeRegex = nonDefaultLocales.join('|')

// Добавление роута для дефолтной локали
// Adding a route for the default locale
if ((options.strategy !== 'prefix' || options.includeUnprefixedFallback) && !parentLocalized) {
const defaultLocalized: LocalizedRoute = { ...route, locale: defaultLocale, parent }
defaultLocalized.meta = { ...defaultLocalized.meta, ...{ locale: true } }
Expand All @@ -152,7 +152,7 @@ export function localizeRoutes(routes: NuxtPage[], options: LocalizeRoutesParams
localizedRoutes.push(redirectLocalized)
}

// Добавление объединенного роута для всех не дефолтных локалей
// Adding a combined route for all non-default locales
const combinedLocalized: LocalizedRoute = { ...route, locale: `/:locale(${localeRegex})`, parent }
let routePath = combinedLocalized.path
if (parentLocalized != null && parentLocalized.path.startsWith('/:locale')) {
Expand Down
10 changes: 5 additions & 5 deletions src/runtime/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ export function detectBrowserLanguage(
export function getHostName() {
let hostName: string | undefined

// Проверяем, выполняется ли код в клиентской части
// Check if the code is running on the client-side
if (import.meta.client) {
hostName = window.location.hostname // Получаем hostname без порта
hostName = window.location.hostname // Get the hostname without the port
}
// Проверяем, выполняется ли код в серверной части
// Check if the code is running on the server-side
else if (import.meta.server) {
const header = useRequestHeaders(['x-forwarded-host', 'host'])

Expand All @@ -337,10 +337,10 @@ export function getHostName() {
detectedHost = header['host']
}

// Если значение в массиве, берём первый элемент, иначе используем как есть
// If the value is an array, take the first element, otherwise use as is
detectedHost = isArray(detectedHost) ? detectedHost[0] : detectedHost

// Если detectedHost содержит порт, извлекаем только часть до двоеточия
// If detectedHost includes a port, extract only the part before the colon
hostName = detectedHost ? detectedHost.split(':')[0] : undefined
}

Expand Down

0 comments on commit 334a4ed

Please sign in to comment.