Skip to content

Commit 5c04ba7

Browse files
committed
Get the byte count of the string.
1 parent 9096eb6 commit 5c04ba7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/diff.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,15 @@ Diff.blobToBuffer= function(
6868
binary_cb,
6969
hunk_cb,
7070
line_cb) {
71-
var bufferLength = !buffer ? 0 : buffer.length;
71+
var bufferText;
72+
var bufferLength;
73+
if (buffer instanceof Buffer) {
74+
bufferText = buffer.toString("utf8");
75+
bufferLength = buffer.length;
76+
} else {
77+
bufferText = buffer;
78+
bufferLength = !buffer ? 0 : Buffer.byteLength(buffer, "utf8");
79+
}
7280

7381
opts = normalizeOptions(opts, NodeGit.DiffOptions);
7482

0 commit comments

Comments
 (0)