From aa58302a27e3692b360b1983e122adf48a53a625 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 25 Feb 2015 17:22:25 -0500 Subject: [PATCH] type check before escape/unescape --- public/src/translator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/src/translator.js b/public/src/translator.js index 80ac3984d7..a6f4027faf 100644 --- a/public/src/translator.js +++ b/public/src/translator.js @@ -32,11 +32,11 @@ }; translator.escape = function(text) { - return text.replace(/\[\[([\S]*?)\]\]/g, '\\[\\[$1\\]\\]'); + return typeof text === 'string' ? text.replace(/\[\[([\S]*?)\]\]/g, '\\[\\[$1\\]\\]') : text; }; translator.unescape = function(text) { - return text.replace(/\\\[\\\[([\S]*?)\\\]\\\]/g, '[[$1]]'); + return typeof text === 'string' ? text.replace(/\\\[\\\[([\S]*?)\\\]\\\]/g, '[[$1]]') : text; }; translator.getLanguage = function() {