Skip to content
Browse files

Fix dependance on prototype for special chars

  • Loading branch information...
1 parent 710b345 commit 7a543abba58489224b0119567caca97fac681ea1 @choan choan committed Nov 4, 2008
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/common.js
View
9 src/common.js
@@ -7,7 +7,14 @@ var JsUnitTest = {
if (typeof object == "string") {
var useDoubleQuotes = arguments[1];
var escapedString = this.gsub(object, /[\x00-\x1f\\]/, function(match) {
- var character = String.specialChar[match[0]];
+ var character = {
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '\\': '\\\\'
+ }[match[0]];
return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
});
if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';

0 comments on commit 7a543ab

Please sign in to comment.
Something went wrong with that request. Please try again.