From 87b1ca0db16bc6e9e440c5a573bedb63bd5361c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chyeonggkim=E2=80=9D?= <“hyeonggkim@smilegate.com”> Date: Thu, 5 Feb 2026 19:21:19 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20CtLayout01=20=EC=BB=A4=EC=8A=A4?= =?UTF-8?q?=ED=85=80=20=EC=BD=98=ED=85=90=EC=B8=A0=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fnCustomVideo 유튜브 팝업 함수 추가 - script/link exclude 속성 지원 - 전역 함수 등록 로직 통합 (registerGlobalFunctions) - CSS Selector injection 보안 취약점 수정 - 사용되지 않는 변수/props 제거 - DOMPurify exclude, defer 속성 허용 Co-Authored-By: Claude Opus 4.5 --- .gitignore | 3 +- i18n.config.ts | 36 +++- layers/components/blocks/Button/ScrollTop.vue | 15 +- layers/components/layouts/Main.vue | 5 +- layers/middleware/init.route.global.ts | 78 ++++---- layers/middleware/pageData.global.ts | 8 +- layers/plugins/dompurify-html.ts | 3 + layers/server/middleware/gameData.ts | 105 ++++------ layers/templates/CtLayout01/index.vue | 189 ++++++++++-------- layers/types/api/pageData.ts | 1 + layers/utils/urlUtil.ts | 111 ++++++---- nuxt.config.ts | 1 + 12 files changed, 321 insertions(+), 234 deletions(-) diff --git a/.gitignore b/.gitignore index a2670c8..1216751 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ logs *.log # Misc -.DS_Store \ No newline at end of file +.DS_Store +CLAUDE.md diff --git a/i18n.config.ts b/i18n.config.ts index 7f1cf93..d0f0896 100644 --- a/i18n.config.ts +++ b/i18n.config.ts @@ -11,6 +11,40 @@ const DEFAULT_LOCALES: Record = { th: { code: 'th', name: 'ภาษาไทย', iso: 'th', dir: 'ltr' }, } const DEFAULT_LOCALE_CODE = 'ko' +const ISO_LANGUAGE_CODES = [ + 'en', // 영어 + 'zh', // 중국어(표준어/만다린) + 'zh-tw', // 중국어(번체) + 'zh-cn', // 중국어(간체) + 'es', // 스페인어 + 'ar', // 아랍어 + 'id', // 인도네시아어 + 'pt', // 포르투갈어 + 'fr', // 프랑스어 + 'ja', // 일본어 + 'ru', // 러시아어 + 'de', // 독일어 + 'hi', // 힌디어 + 'vi', // 베트남어 + 'tr', // 터키어 + 'ko', // 한국어 + 'it', // 이탈리아어 + 'bn', // 벵골어 + 'pl', // 폴란드어 + 'th', // 태국어 + 'fa', // 페르시아어 + 'nl', // 네덜란드어 + 'ur', // 우르두어 + 'te', // 텔루구어 + 'mr', // 마라티어 + 'ta', // 타밀어 + 'tl', // 타갈로그어(필리핀어) + 'uk', // 우크라이나어 + 'sw', // 스와힐리어 + 'ro', // 루마니아어 + 'hu', // 헝가리어 + 'ms', // 말레이어 +] // getI18n 함수가 NuxtI18nOptions 타입의 값을 반환하도록 명시적으로 타입을 지정합니다. const getI18n = (allowedLangCodes?: string[]): NuxtI18nOptions => { @@ -52,4 +86,4 @@ const getI18n = (allowedLangCodes?: string[]): NuxtI18nOptions => { } } -export { DEFAULT_LOCALE_CODE, DEFAULT_COVERAGES, getI18n } +export { DEFAULT_LOCALE_CODE, ISO_LANGUAGE_CODES, getI18n } diff --git a/layers/components/blocks/Button/ScrollTop.vue b/layers/components/blocks/Button/ScrollTop.vue index 7e73f0d..dd9b207 100644 --- a/layers/components/blocks/Button/ScrollTop.vue +++ b/layers/components/blocks/Button/ScrollTop.vue @@ -1,5 +1,11 @@ - - + diff --git a/layers/types/api/pageData.ts b/layers/types/api/pageData.ts index fff3406..9ad514a 100644 --- a/layers/types/api/pageData.ts +++ b/layers/types/api/pageData.ts @@ -33,6 +33,7 @@ export interface PageDataValue { is_login_required: number meta_tag_type: number use_top_btn: boolean + top_btn_color_json?: ColorObject use_sns_btn: boolean use_lnb: boolean lnb_text_color_code_active?: string diff --git a/layers/utils/urlUtil.ts b/layers/utils/urlUtil.ts index b9c379d..4143dca 100644 --- a/layers/utils/urlUtil.ts +++ b/layers/utils/urlUtil.ts @@ -9,6 +9,13 @@ export const isExternalUrl = (url: string): boolean => { return url.startsWith('http://') || url.startsWith('https://') } +/** + * 경로에 쿼리스트링을 추가하는 함수 + */ +export const addQueryString = (path: string, queryString: string): string => { + return queryString ? `${path}?${queryString}` : path +} + /** * 게임 도메인을 추출하는 함수 * 서버와 클라이언트 환경에서 모두 동작 @@ -95,55 +102,83 @@ export const getPathAfterLanguage = (url: string): string => { } /** - * intro page_url을 기반으로 리다이렉트 경로를 생성하는 공통 함수 - * @param introPageUrl - intro.page_url 값 - * @param langCode - 현재 언어 코드 - * @param currentUrl - 현재 접근한 URL (쿼리스트링 포함, 옵션) - * @returns 최종 리다이렉트 경로 (없으면 기본값 /home) + * URL을 파싱하여 최종 경로를 반환하는 함수 + * 경로가 '/' 또는 ''이고 인트로 URL이 있으면 인트로로 리다이렉트, + * 그렇지 않으면 언어 코드를 추가한 URL을 반환 + * SSR과 CSR 모두에서 작동 + * @param url - URL 문자열 + * @param finalLocale - 최종 언어 코드 + * @param langCodes - 지원하는 언어 코드 배열 + * @param ISO_LANGUAGE_CODES - ISO 언어 코드 배열 + * @param introPageUrl - 인트로 페이지 URL (선택) + * @returns 최종 URL 문자열 */ -export const getIntroRedirectPath = ( - introPageUrl: string | undefined | null, - langCode: string, - currentUrl?: string +export const parseUrl = ( + url: string, + finalLocale: string, + langCodes: string[], + ISO_LANGUAGE_CODES: string[], + introPageUrl?: string ): string => { - // 기본값: /langCode/home - let defaultPath = `/${langCode}/home` + const [pathPart, queryString = ''] = url.split('?') + const pathSegments = pathPart.split('/').filter(Boolean) + const currentLocale = pathSegments[0] + const isKnownLocale = + langCodes.includes(currentLocale) || + ISO_LANGUAGE_CODES.includes(currentLocale) + const isEmptyPath = + pathSegments.length === 0 || (pathSegments.length === 1 && isKnownLocale) - if (introPageUrl && introPageUrl.trim() !== '') { - if (isExternalUrl(introPageUrl)) { - // 외부 URL인 경우 그대로 사용 - defaultPath = introPageUrl - } else { - // 내부 경로인 경우 언어 코드 패턴 확인 - const normalizedIntroUrl = introPageUrl.split('?')[0] // 쿼리스트링 제외 - const languagePattern = /^\/[a-z]{2}(-[a-z]{2})?(\/|$)/ - const hasLanguageCode = languagePattern.test(normalizedIntroUrl) + // 경로가 '/' 또는 ''인 경우 인트로 URL 처리 + if (isEmptyPath) { + const hasIntroUrl = introPageUrl?.trim() + if (hasIntroUrl) { + // 외부 URL인 경우 그대로 반환 + if (isExternalUrl(introPageUrl)) { + return introPageUrl + } + // 내부 경로인 경우 언어 코드 추가 + // 인트로 URL이 이미 언어 코드로 시작하는지 확인 + const introPathSegments = introPageUrl.split('/').filter(Boolean) + const introFirstSegment = introPathSegments[0] + const introHasLocale = + introFirstSegment && + (langCodes.includes(introFirstSegment) || + ISO_LANGUAGE_CODES.includes(introFirstSegment)) - if (hasLanguageCode) { - // 이미 언어 코드가 있으면 그대로 사용 - defaultPath = introPageUrl + let introPath: string + if (introHasLocale) { + // 이미 언어 코드가 있으면 언어 코드만 교체 + introPath = '/' + [finalLocale, ...introPathSegments.slice(1)].join('/') } else { // 언어 코드가 없으면 추가 - const pathWithSlash = normalizedIntroUrl.startsWith('/') - ? normalizedIntroUrl - : `/${normalizedIntroUrl}` - defaultPath = `/${langCode}${pathWithSlash}` - - // 쿼리스트링이 있으면 다시 추가 - if (introPageUrl.includes('?')) { - defaultPath += '?' + introPageUrl.split('?')[1] - } + introPath = `/${finalLocale}${introPageUrl}` } + return addQueryString(introPath, queryString) } + // 인트로 URL이 없으면 기본 홈 경로 반환 + return addQueryString(`/${finalLocale}/home`, queryString) } - // intro에 쿼리스트링이 없고, 현재 URL에 쿼리스트링이 있으면 추가 - if (!defaultPath.includes('?') && currentUrl && currentUrl.includes('?')) { - const queryString = currentUrl.split('?')[1] - if (queryString) { - defaultPath += '?' + queryString + // 리다이렉트 경로 생성 + const remainingPath = pathSegments.slice(1) + const hasRemainingPath = remainingPath.length > 0 + let newPath: string + + if (isKnownLocale) { + // 현재 언어 코드와 최종 언어가 같으면 리다이렉트 불필요 + if (currentLocale === finalLocale) return url + + // 유효한 언어 코드가 있지만 다른 언어인 경우 + if (hasRemainingPath) { + // 경로가 있으면 언어 코드만 교체 (/vi/story -> /finalLocale/story) + newPath = '/' + [finalLocale, ...remainingPath].join('/') } + } else { + // 언어 코드가 없거나 유효하지 않은 경우: 언어 코드를 앞에 추가 + const pathWithoutSlash = pathPart === '/' ? '' : pathPart + newPath = `/${finalLocale}${pathWithoutSlash}` } - return defaultPath + return addQueryString(newPath, queryString) } diff --git a/nuxt.config.ts b/nuxt.config.ts index 314d4ba..b227a5a 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -116,6 +116,7 @@ export default defineNuxtConfig({ }, experimental: { payloadExtraction: false, + entryImportMap: false, }, nitro: { prerender: { routes: [] },