Sink/app/utils/flag.ts
wudi 7cadbfe2b1 refactor: Migrate project files and directories to the app directory using the new compatibilityVersion: 4 feature
- Moved `app.config.ts` to the `app` directory
- Migrated `.vue` files and other assets to the `app` directory
- Updated import paths to reflect the new file locations
2025-03-24 11:05:59 +08:00

8 lines
324 B
TypeScript

const EMOJI_FLAG_UNICODE_STARTING_POSITION = 127397
export function getFlag(countryCode: string) {
const regex = /^[A-Z]{2}$/.test(countryCode)
if (!countryCode || !regex)
return void 0
return String.fromCodePoint(...countryCode.split('').map(char => EMOJI_FLAG_UNICODE_STARTING_POSITION + char.charCodeAt(0)))
}