Skip to content

Commit 62dab3b

Browse files
committed
feat(utils): add isInternalPath utility function
1 parent b710e94 commit 62dab3b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/module.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ import { setupDevToolsUI } from './devtools'
2626
import { PageManager } from './page-manager'
2727
import type { PluginsInjections } from './runtime/plugins/01.plugin'
2828
import { LocaleManager } from './locale-manager'
29-
30-
const isInternalPath = (p: string) => /(?:^|\/)__[^/]+/.test(p)
29+
import { isInternalPath } from './utils'
3130

3231
function generateI18nTypes() {
3332
return `
@@ -487,7 +486,7 @@ export default defineNuxtModule<ModuleOptions>({
487486
}
488487
})
489488
routesToRemove.forEach(route => routesSet.delete(route))
490-
489+
491490
const additionalRoutes = new Set<string>()
492491
// Проходим по каждому существующему маршруту и добавляем локализованные версии
493492
routesSet.forEach((route) => {

src/page-manager.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
buildRouteName,
1010
cloneArray,
1111
extractLocaleRoutes,
12+
isInternalPath,
1213
isLocaleDefault,
1314
isPageRedirectOnly,
1415
normalizePath,
@@ -20,8 +21,6 @@ const buildRouteNameFromRoute = (name: string | null | undefined, path: string |
2021
return name ?? (path ?? '').replace(/[^a-z0-9]/gi, '-').replace(/^-+|-+$/g, '')
2122
}
2223

23-
const isInternalPath = (p: string) => /(?:^|\/)__[^/]+/.test(p)
24-
2524
export class PageManager {
2625
locales: Locale[]
2726
defaultLocale: Locale
@@ -66,7 +65,7 @@ export class PageManager {
6665
if (page.path && isInternalPath(page.path)) {
6766
continue
6867
}
69-
68+
7069
// if (this.isAlreadyLocalized(page.path!)) continue
7170
if (!page.name && page.file?.endsWith('.vue')) {
7271
console.warn(`[nuxt-i18n-next] Page name is missing for the file: ${page.file}`)

src/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import path from 'node:path'
22
import type { NuxtPage } from '@nuxt/schema'
33
import type { Locale, LocaleCode } from 'nuxt-i18n-micro-types'
44

5+
export const isInternalPath = (p: string) => /(?:^|\/)__[^/]+/.test(p)
6+
57
export function extractLocaleRoutes(content: string, filePath: string): Record<string, string> | null {
68
// Ищем вызов defineI18nRoute (с долларом или без)
79
const defineMatch = content.match(/\$?\bdefineI18nRoute\s*\(\s*\{[\s\S]*?\}\s*\)/)

0 commit comments

Comments
 (0)