freeleaps-authentication/common/utils/region.py

13 lines
421 B
Python
Raw Permalink Normal View History

2025-10-30 03:26:05 +00:00
from common.constants.region import UserRegion
class RegionHandler:
def __init__(self):
self._zh_cn_patterns = [".cn", "cn.", "host"]
def detect_from_host(self, host: str) -> UserRegion:
# Now we set user preferred region based on host
for parttern in self._zh_cn_patterns:
if parttern in host.lower():
return UserRegion.ZH_CN
return UserRegion.OTHER