@@ -519,31 +519,30 @@ private function setPath($path)
519519 return ;
520520 }
521521
522- $ parts = pathinfo ( $ path );
522+ $ file = substr ( strrchr ( $ path, ' / ' ), 1 );
523523
524- $ this ->info ['path ' ] = [];
525-
526- if (isset ($ parts ['dirname ' ])) {
527- foreach (explode ('/ ' , str_replace (DIRECTORY_SEPARATOR , '/ ' , $ parts ['dirname ' ])) as $ dir ) {
528- $ dir = trim (urldecode ($ dir ));
524+ if ($ file !== '' ) {
525+ $ path = substr ($ path , 0 , -strlen ($ file ));
526+ }
529527
530- if ($ dir !== '' ) {
531- $ this ->info ['path ' ][] = $ dir ;
532- }
528+ if ($ file ) {
529+ if (preg_match ('/(.*)\.([\w]+)$/ ' , $ file , $ match )) {
530+ $ this ->info ['file ' ] = $ match [1 ];
531+ $ this ->info ['extension ' ] = $ match [2 ];
532+ } else {
533+ $ this ->info ['file ' ] = $ file ;
534+ $ this ->info ['extension ' ] = null ;
533535 }
534536 }
535537
536- $ this ->info ['file ' ] = isset ($ parts ['filename ' ]) ? $ parts ['filename ' ] : null ;
537- $ this ->info ['extension ' ] = isset ($ parts ['extension ' ]) ? $ parts ['extension ' ] : null ;
538- $ this ->info ['content ' ] = null ;
539-
540- // bugfix /wiki/Supernatural_(U.S._TV_series) is parsed as:
541- // path: /wiki/
542- // file: Supernatural_(U.S
543- // extension: _TV_series)
544- if (!empty ($ this ->info ['extension ' ]) && !preg_match ('/^\w+$/ ' , $ this ->info ['extension ' ])) {
545- $ this ->info ['file ' ] .= '. ' .$ this ->info ['extension ' ];
546- $ this ->info ['extension ' ] = null ;
538+ $ this ->info ['path ' ] = [];
539+
540+ foreach (explode ('/ ' , $ path ) as $ dir ) {
541+ $ dir = trim (urldecode ($ dir ));
542+
543+ if ($ dir !== '' ) {
544+ $ this ->info ['path ' ][] = $ dir ;
545+ }
547546 }
548547 }
549548}
0 commit comments