From d6d55c9f9c61e0f3cd0e92a106f94b9fd31da2d3 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sun, 3 May 2020 17:27:13 +0200 Subject: [PATCH] Do not restrict language codes to two characters In fact, they may be of 2-8 characters in length according to [BCP 47] 2.2.1. I do not really see any reason to validate them anyway, and this way we could also support e.g. `en-US` vs `en-GB`. [BCP 47]: https://tools.ietf.org/rfc/bcp/bcp47.txt --- app/loc.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/loc.js b/app/loc.js index a1a6015..a483154 100644 --- a/app/loc.js +++ b/app/loc.js @@ -31,12 +31,7 @@ var _data = {}; * @author svartoyg */ async function retrieveData (language) { - const regexp = (new RegExp("^([a-z]{2})$")); - if (regexp.exec(language) === null) { - return Promise.reject(new Error('invalid language code "' + language + '"')); - } else { - return (await import(`../loc/${language}.json`)).default - } + return (await import(`../loc/${language}.json`)).default }