From c812abe13967d58f41eac357c31585a596033e89 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Sun, 26 Nov 2023 01:48:16 +0900 Subject: [PATCH] fix internal paths --- assets/js/misc/index.ts | 5 +++++ components/content/ProseA.vue | 5 +++-- components/g/NuxtLink.vue | 4 ++-- layouts/docs.vue | 15 +++++++++++++-- nuxt.config.ts | 2 +- server/plugins/i18nRedirector.ts | 2 +- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/assets/js/misc/index.ts b/assets/js/misc/index.ts index 35a85fc8..d124b011 100644 --- a/assets/js/misc/index.ts +++ b/assets/js/misc/index.ts @@ -43,6 +43,11 @@ export function isLocalPath(link: string, base?: string): boolean { return (!url.host || rootDomain.host === url.host); } +export function sanitizeInternalPath(path: string): string { + const runtimeConfig = useRuntimeConfig(); + return path.replace(new RegExp(`^(\/(${runtimeConfig.public.locales.map((l) => l.code).join('|')})\/?){2,}(.*)$`, 'g'), '$1$2'); +} + /** * ナビゲーションObjectを合致する条件まで深掘り * @param obj ナビゲーションObject diff --git a/components/content/ProseA.vue b/components/content/ProseA.vue index 6d137e55..5c3a3775 100644 --- a/components/content/ProseA.vue +++ b/components/content/ProseA.vue @@ -1,6 +1,7 @@