diff --git a/public/src/modules/translator.common.js b/public/src/modules/translator.common.js index 49a3b59c60..c69a9cc265 100644 --- a/public/src/modules/translator.common.js +++ b/public/src/modules/translator.common.js @@ -463,7 +463,9 @@ module.exports = function (utils, load, warn) { * @returns {string} */ Translator.escape = function escape(text) { - return typeof text === 'string' ? text.replace(/\[\[/g, '[[').replace(/\]\]/g, ']]') : text; + return typeof text === 'string' ? + text.replace(/\[\[/g, '[[').replace(/\]\]/g, ']]') : + text; }; /** @@ -473,8 +475,7 @@ module.exports = function (utils, load, warn) { */ Translator.unescape = function unescape(text) { return typeof text === 'string' ? - text.replace(/[/g, '[').replace(/\\\[/g, '[') - .replace(/]/g, ']').replace(/\\\]/g, ']') : + text.replace(/]]/g, ']]').replace(/[[/g, '[[') : text; }; diff --git a/test/translator.js b/test/translator.js index 6e34012a7a..61c3d5af8e 100644 --- a/test/translator.js +++ b/test/translator.js @@ -308,10 +308,6 @@ describe('Translator static methods', () => { describe('.unescape', () => { it('should unescape escaped translation patterns within text', (done) => { - assert.strictEqual( - Translator.unescape('some nice text \\[\\[global:home\\]\\] here'), - 'some nice text [[global:home]] here' - ); assert.strictEqual( Translator.unescape('some nice text [[global:home]] here'), 'some nice text [[global:home]] here'