Fix(routes): Hardern add-lang middleware against short urls

This commit is contained in:
Berkeley Martinez
2016-09-09 00:39:03 -07:00
parent dff2c4b576
commit 98763f5fd0

View File

@ -12,7 +12,7 @@ const toLowerCase = String.prototype.toLowerCase;
function langRedirect(...args) { function langRedirect(...args) {
const url = args.length === 2 ? args[1] : args[0]; const url = args.length === 2 ? args[1] : args[0];
const { lang } = this.req; const { lang } = this.req;
const maybeLang = toLowerCase.call(url.split('/')[1]); const maybeLang = toLowerCase.call((url.split('/')[1] || ''));
if ( if (
passthroughs[maybeLang] || passthroughs[maybeLang] ||