This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Closes GH-310 Format slashes properly

  • Loading branch information...
1 parent a7254f3 commit 4d64f363385be9d5e83ededd70faf91ebc6e792b @isaacs isaacs committed with ry Mar 29, 2011
Showing with 5 additions and 4 deletions.
  1. +3 −3 lib/util.js
  2. +2 −1 test/simple/test-console.js
View
@@ -118,9 +118,9 @@ exports.inspect = function(obj, showHidden, depth, colors) {
return stylize('undefined', 'undefined');
case 'string':
- var simple = JSON.stringify(value).replace(/'/g, "\\'")
- .replace(/\\"/g, '"')
- .replace(/(^"|"$)/g, "'");
+ var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
+ .replace(/'/g, "\\'")
+ .replace(/\\"/g, '"') + '\'';
return stylize(simple, 'string');
case 'number':
@@ -31,11 +31,12 @@ global.process.stdout.write = function(string) {
console.log('foo');
console.log('foo', 'bar');
console.log('%s %s', 'foo', 'bar', 'hop');
+console.log({slashes: '\\\\'})
global.process.stdout.write = stdout_write;
assert.equal('foo\n', strings.shift());
assert.equal('foo bar\n', strings.shift());
assert.equal('foo bar hop\n', strings.shift());
-
+assert.equal("{ slashes: '\\\\\\\\' }\n", strings.shift());
assert.equal(true, process.stderr.write("hello world"));

0 comments on commit 4d64f36

Please sign in to comment.