on master help sign in
Merge pull request #337 from rosano/patch-1

Use non-hyphenated code when matching language

commitcd997a91df264429d05f9e543d0916694be84702 authorChris <ckipp@pm.me> dateWed 23 Oct 2019, 21:29 (7 years ago) parentc158476ed691dc
1 file changed+3−1
scripts/portal.js+3−1
scripts/portal.js+3−1
@@ -71,8 +71,10 @@ function Portal (sites) {
7171 setTimeout(() => { window.location.href = target }, 3000)
7272 }
7373
74+ this.navLangs = [... new Set(navigator.languages.map(lang => lang.split('-').shift()))]
75+
7476 this.sitesMatchingLangs = this.sites
75− .filter(site => site.langs && site.langs.some(lang => navigator.languages.includes(lang)))
77+ .filter(site => site.langs && site.langs.some(lang => this.navLangs.includes(lang)))
7678
7779 this.nextSiteIndex = (ceiling, index) => index === ceiling ? 0 : index + 1
7880 this.randomSite = this.sitesMatchingLangs[Math.floor(Math.random() * this.sitesMatchingLangs.length)]