Skip to content

Commit eaa3747

Browse files
committed
Fix+File: don't pass the file.name in the regex like the distant files
1 parent 5e9d549 commit eaa3747

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

api/file.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,31 @@ var
88
extArray = "mp3-mp4-mpeg-ogg-wav-webm-mpg-weba-ogm-srt-vtt".split( "-" )
99
;
1010

11-
api.file = function( file ) {
12-
var
13-
ind,
14-
url = file.name || file.url,
15-
reg = url.match( /([^/?#]*)\.([^./?#]+)/g )
16-
;
11+
function cutName( that, s ) {
12+
s = s || "";
13+
var i = s.lastIndexOf( "." );
14+
that.name = i < 0 ? s : s.substr( 0, i );
15+
that.extension = i < 0 ? "" : s.substr( i + 1 ).toLowerCase();
16+
}
1717

18-
this.name = url;
19-
if ( reg ) {
20-
reg = reg[ reg.length - 1 ];
21-
ind = reg.lastIndexOf( "." );
22-
this.name = reg;
23-
if ( ind >= 0 ) {
24-
this.name = reg.substr( 0, ind );
25-
this.extension = reg.substr( ind + 1 ).toLowerCase();
26-
}
18+
api.file = function( file ) {
19+
var name = file.name || file.url;
20+
this.isLocal = !!file.name;
21+
if ( !this.isLocal ) {
22+
name = name.match( /([^/?#]*)\.([^./?#]+)/g );
23+
name = name && name[ name.length - 1 ];
2724
}
25+
cutName( this, name );
2826

2927
this.isSupported = $.inArray( this.extension, extArray ) > -1;
30-
this.isLocal = !!file.name;
31-
3228
if ( this.isSupported ) {
3329
this.type =
3430
extAudio.indexOf( this.extension ) > -1 ? "audio" :
3531
extVideo.indexOf( this.extension ) > -1 ? "video" : "text";
3632
if ( this.isLocal ) {
3733
this.dataFile = file;
3834
} else {
39-
this.url = url;
35+
this.url = file.url;
4036
this.cors = file.cors;
4137
}
4238
}

0 commit comments

Comments
 (0)