File tree Expand file tree Collapse file tree 3 files changed +16
-20
lines changed Expand file tree Collapse file tree 3 files changed +16
-20
lines changed Original file line number Diff line number Diff line change 8
8
extArray = "mp3-mp4-mpeg-ogg-wav-webm-mpg-weba-ogm-srt-vtt" . split ( "-" )
9
9
;
10
10
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
+ }
17
17
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 ] ;
27
24
}
25
+ cutName ( this , name ) ;
28
26
29
27
this . isSupported = $ . inArray ( this . extension , extArray ) > - 1 ;
30
- this . isLocal = ! ! file . name ;
31
-
32
28
if ( this . isSupported ) {
33
29
this . type =
34
30
extAudio . indexOf ( this . extension ) > - 1 ? "audio" :
35
31
extVideo . indexOf ( this . extension ) > - 1 ? "video" : "text" ;
36
32
if ( this . isLocal ) {
37
33
this . dataFile = file ;
38
34
} else {
39
- this . url = url ;
35
+ this . url = file . url ;
40
36
this . cors = file . cors ;
41
37
}
42
38
}
You can’t perform that action at this time.
0 commit comments