type check before escape/unescape

This commit is contained in:
psychobunny
2015-02-25 17:22:25 -05:00
parent e90f3bf7c8
commit aa58302a27

View File

@@ -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() {