Skip to content

Commit e66ea67

Browse files
committed
Fix tests and enable quoting things containing backslashes
1 parent 00b9395 commit e66ea67

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

quote.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = function quote(xs) {
88
if (s && typeof s === 'object') {
99
return s.op.replace(/(.)/g, '\\$1');
1010
}
11-
if ((/["\s]/).test(s) && !(/'/).test(s)) {
11+
if ((/["\s\\]/).test(s) && !(/'/).test(s)) {
1212
return "'" + s.replace(/(['])/g, '\\$1') + "'";
1313
}
1414
if ((/["'\s]/).test(s)) {

test/quote.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ test('quote', function (t) {
2222
t.equal(quote(['><;{}']), '\\>\\<\\;\\{\\}');
2323
t.equal(quote(['a', 1, true, false]), 'a 1 true false');
2424
t.equal(quote(['a', 1, null, undefined]), 'a 1 null undefined');
25-
t.equal(quote(['a\\x']), 'a\\\\x');
25+
t.equal(quote(['a\\x']), "'a\\x'");
2626
t.equal(quote(['a"b']), `'a"b'`);
2727
t.equal(quote(['"a"b"']), `'"a"b"'`);
28-
t.equal(quote(['a\\"b']), `'a\"b'`);
29-
t.equal(quote(['a\\b']), `'a\b'`);
28+
t.equal(quote(['a\\"b']), `'a\\"b'`);
29+
t.equal(quote(['a\\b']), `'a\\b'`);
3030
t.end();
3131
});
3232

0 commit comments

Comments
 (0)