florrain / locale

Browser locale negotiation for node.js
MIT License
257 stars 36 forks source link

TypeError in Locale initializer. #5

Closed jdreux closed 11 years ago

jdreux commented 11 years ago

Getting the following exception in certain cases:

TypeError: Cannot read property '0' of null at new Locale (/lexit/public-ws/node_modules/locale/lib/index.js:26:52) at new Locales (/lexit/public-ws/node_modules/locale/lib/index.js:64:18)

Can't be more specific on the actual circumstances because this happen in a production server.

The problem seems to be around this code:

function Locale(str) { var country, language, _ref; if (!str) return; --> _ref = str.match(/[a-z]+/gi), language = _ref[0], country = _ref[1]; this.language = language.toLowerCase(); if (country) this.country = country.toUpperCase(); }