Skip to content

Commit 9f2ec36

Browse files
committed
fix(File): extname matcher now accept undefined path
fix a exception when construct a File with a Stream without path
1 parent 722faed commit 9f2ec36

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/file.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = function(AV) {
1616
// port from browserify path module
1717
// since react-native packager won't shim node modules.
1818
const extname = (path) => {
19+
if (!_.isString(path)) return '';
1920
return path.match(/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/)[4];
2021
};
2122

@@ -127,7 +128,7 @@ module.exports = function(AV) {
127128
}
128129

129130
if (!process.env.CLIENT_PLATFORM) {
130-
if (data instanceof require('stream')) {
131+
if (data instanceof require('stream') && data.path) {
131132
this._extName = extname(data.path);
132133
}
133134
if (Buffer.isBuffer(data)) {

0 commit comments

Comments
 (0)