export const LanguageType = {
    ENGLISH: 'en',
    CHINESE: 'zh',
}

export function language(request) {
    if (!isOfficalHost(request)) {
        return LanguageType.ENGLISH
    } else {
        const {host} = new URL(request.url)
        if (host === 'ecatest.cdnetworks.com') {
            return LanguageType.ENGLISH
        } else {
            return LanguageType.CHINESE
        }
    }
}

export function englishPage(request) {
    return language(request) === LanguageType.ENGLISH
}

export function isOfficalHost(request) {
    const {host} = new URL(request.url)
    return host !== 'ecatest.haplat.net'
}