git ssb

30+

cel / git-ssb-web



Commit 88de0177402d7aacfb3a27acbb67242d60c3cc39

Ensure a locale gets picked

Prevent crash on undefined locale
cel committed on 1/16/2017, 2:35:00 AM
Parent: da58eab18cff4dbda3c42614aab7bb8cb36cce4f

Files changed

index.jschanged
index.jsView
@@ -211,13 +211,12 @@
211211 req._u = url.parse(req.url, true)
212212 var locale = req._u.query.locale ||
213213 (/locale=([^;]*)/.exec(req.headers.cookie) || [])[1]
214214 var reqLocales = req.headers['accept-language']
215- var locales = String(reqLocales).split(/, */).map(function (item) {
215 + var locales = reqLocales ? reqLocales.split(/, */).map(function (item) {
216216 return item.split(';')[0]
217- })
218- if (locales)
219- req._locale = locales[0]
217 + }) : []
218 + req._locale = locales[0] || locale || this.i18n.fallback
220219
221220 this.i18n.pickCatalog(reqLocales, locale, function (err, t) {
222221 if (err) return pull(this.serveError(req, err, 500), serve(req, res))
223222 req._t = t

Built with git-ssb-web