Skip to content

Commit 52b64ae

Browse files
committed
workaround typedarray subarray bug that breaks content-type detection in some cases
1 parent 80542c5 commit 52b64ae

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
### v0.25.1
4+
* Workaround for browser bug that was breaking automatic content-type detection in certain cases
5+
36
### v0.25.0
47
* Fixed bug with recognizeStream failing to auto-detect content-type
58
* RecognizeStream no longer sets any default options

speech-to-text/recognize-stream.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ RecognizeStream.prototype.promise = require('./to-promise');
407407

408408

409409
RecognizeStream.getContentType = function(buffer) {
410-
return contentType(buffer.slice(0, 4).toString());
410+
// the substr really shouldn't be necessary, but there's a bug somewhere that can cause buffer.slice(0,4) to return
411+
// the entire contents of the buffer, so it's a failsafe to catch that
412+
return contentType(buffer.slice(0, 4).toString().substr(0,4));
411413
};
412414

413415

0 commit comments

Comments
 (0)