Merge pull request #10527 from BerkeleyTrue/fix/harden-add-lang

Fix(routes): Hardern add-lang middleware against short urls
This commit is contained in:
Quincy Larson
2016-09-09 00:50:04 -07:00
committed by GitHub

View File

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