Skip to content

Commit b11f500

Browse files
authored
Fix: BinData.toString() wraps base64 in quotes (#15)
This just aligns more closely with the legacy shell / `$function` in the server.
1 parent 511d16c commit b11f500

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

snippets/mongocompat/mongotypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ if (typeof (BinData) != "undefined") {
548548
if (encoding) {
549549
return this.nativeToString(encoding);
550550
}
551-
return `BinData(${this.type}, ${this.base64()})`;
551+
return `BinData(${this.type},"${this.base64()}")`;
552552
};
553553

554554
BinData.prototype.base64 = function () {

snippets/mongocompat/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
load(__dirname + '/index.js');
22

33
assert.strictEqual(ObjectId('0123456789abcdef01234567').tojson(), 'ObjectId("0123456789abcdef01234567")');
4+
assert.strictEqual(BinData(4, 'abcdefgh').toString(), 'BinData(4,"abcdefgh")');

0 commit comments

Comments
 (0)