Skip to content

refactor(config): basePath 정규화 로직을 단일 유틸리티로 통합 - #93

Merged
CoBool merged 1 commit into
mainfrom
refactor/base-path-utility
Aug 16, 2026
Merged

refactor(config): basePath 정규화 로직을 단일 유틸리티로 통합#93
CoBool merged 1 commit into
mainfrom
refactor/base-path-utility

Conversation

@CoBool

@CoBool CoBool commented Aug 16, 2026

Copy link
Copy Markdown
Owner

변경 내용

  • NEXT_PUBLIC_BASE_PATH 환경변수의 슬래시 정규화 및 접두사 결합 로직을 담당하는 src/lib/base-path.ts 유틸리티 모듈 생성
    • getBasePath(): 선행 슬래시 보장 및 후행 슬래시 제거, 미설정 시 빈 문자열 반환
    • prefixBasePath(path): 정규화된 basePath를 대상 경로 앞에 안전하게 결합
  • src/app/manifest.ts, src/components/markdown-content.tsx, src/features/search/pagefind.ts에서 각각 복제 구현되어 있던 로직을 prefixBasePath로 통일
  • 다양한 엣지 케이스(undefined, 공백, /, /repo/, repo/, 중첩 경로 등)에 대한 단위 테스트(tests/base-path.test.ts) 추가

변경 이유

  • GitHub Pages 서브디렉터리(e.g., /repo/) 배포 환경을 지원하기 위한 basePath 정규화 코드가 4곳 이상에 인라인으로 중복 구현되어 있었습니다.
  • 정규화 규칙이 모듈마다 미묘하게 달라질 위험을 방지하고 단일 원천(Single Source of Truth)으로 중앙화하여 정적 배포 정합성을 보장하기 위함입니다.

검증

  • pnpm lint: 통과
  • pnpm typecheck: 통과
  • pnpm test: tests/base-path.test.ts 포함 33개 테스트 파일 / 234개 테스트 전체 통과
  • pnpm build: SSG 정적 빌드 및 Pagefind 색인 생성 성공

- NEXT_PUBLIC_BASE_PATH 정규화 및 접두사 연결 로직을 src/lib/base-path.ts로 중앙화
- manifest.ts, markdown-content.tsx, pagefind.ts에서 중복 구현된 로직을 prefixBasePath로 교체
- basePath 유틸리티에 대한 엣지 케이스 단위 테스트(tests/base-path.test.ts) 추가
@CoBool
CoBool force-pushed the refactor/base-path-utility branch from 826a10c to e727902 Compare August 16, 2026 12:15
@CoBool
CoBool merged commit 434ce1d into main Aug 16, 2026
1 check passed
@CoBool
CoBool deleted the refactor/base-path-utility branch August 16, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant