import { locales } from '@/i18n/config';

const LOCALE_PREFIX_RE = new RegExp(`^\\/(${locales.join('|')})(/|$)`);
const LOCALE_PREFIX_SLASH_RE = new RegExp(`^\\/(${locales.join('|')})\\/`);

/** URL에서 locale prefix 제거 (/ko/hr/... → /hr/...) */
export function stripLocalePrefix(path: string): string {
  return path.replace(LOCALE_PREFIX_RE, '/');
}

/** path 내부의 locale prefix만 제거 (슬래시 필수) */
export function stripLocaleSlashPrefix(path: string): string {
  return path.replace(LOCALE_PREFIX_SLASH_RE, '/');
}
