diff --git a/js/translator.js b/js/translator.js index 73de6778..34bbb717 100644 --- a/js/translator.js +++ b/js/translator.js @@ -218,10 +218,10 @@ var Translator = (function() { for (var first in translations) {break;} if (first) { - Log.log("Loading core translation fallback file: " + translations[first]); - loadJSON(translations[first], function(translations) { - self.coreTranslationsFallback = translations; - }); + Log.log("Loading core translation fallback file: " + translations[first]); + loadJSON(translations[first], function(translations) { + self.coreTranslationsFallback = translations; + }); } }, }; diff --git a/tests/configs/data/StripComments.json b/tests/configs/data/StripComments.json new file mode 100644 index 00000000..62d5d618 --- /dev/null +++ b/tests/configs/data/StripComments.json @@ -0,0 +1,13 @@ +{ + // Escaped + "FOO\"BAR": "Today", + + /* + * The following lines + * represent cardinal directions + */ + "N": "N", + "E": "E", + "S": "S", + "W": "W" +} diff --git a/tests/unit/classes/translator_spec.js b/tests/unit/classes/translator_spec.js index 4f995391..fe1ce809 100644 --- a/tests/unit/classes/translator_spec.js +++ b/tests/unit/classes/translator_spec.js @@ -2,6 +2,7 @@ const chai = require("chai"); const expect = chai.expect; const path = require("path"); const fs = require("fs"); +const helmet = require("helmet"); const {JSDOM} = require("jsdom"); const express = require("express"); @@ -10,12 +11,12 @@ describe("Translator", function() { before(function() { const app = express(); - - app.get("/translations/:file", function(req, res) { - res.status(200) - .header("Access-Control-Allow-Origin", "*") - .json(require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", req.params.file))); + app.use(helmet()); + app.use(function (req, res, next) { + res.header("Access-Control-Allow-Origin", "*"); + next(); }); + app.use("/translations", express.static(path.join(__dirname, "..", "..", "..", "tests", "configs", "data"))); server = app.listen(3000); }); @@ -180,6 +181,26 @@ describe("Translator", function() { }; }); + it("should strip comments", function(done) { + const dom = new JSDOM(`\ - \ - \ - \ + \ - \ +