@@ -48,28 +48,31 @@ describe('Utils', function () {
4848
4949 describe ( '#getFilenameFromUrl(url)' , function ( ) {
5050 it ( 'should return last path item as filename & trim all after first ? or #' , function ( ) {
51- utils . getFilenameFromUrl ( 'http://example.com/index.html' ) . should . equalFileSystemPath ( 'index.html' ) ;
52- utils . getFilenameFromUrl ( 'http://example.com/p/a/t/h/index.html' ) . should . equalFileSystemPath ( 'index.html' ) ;
53- utils . getFilenameFromUrl ( 'http://example.com/index.html?12' ) . should . equalFileSystemPath ( 'index.html' ) ;
54- utils . getFilenameFromUrl ( 'http://example.com/index.html#t?12' ) . should . equalFileSystemPath ( 'index.html' ) ;
55- utils . getFilenameFromUrl ( 'http://example.com/index.html?12#t' ) . should . equalFileSystemPath ( 'index.html' ) ;
56- utils . getFilenameFromUrl ( 'http://example.com/?12_jdlsk' ) . should . be . empty ( ) ;
57- utils . getFilenameFromUrl ( 'http://example.com/#index.html' ) . should . be . empty ( ) ;
58- utils . getFilenameFromUrl ( 'http://example.com/' ) . should . be . empty ( ) ;
51+ utils . getFilenameFromUrl ( 'http://example.com/index.html' ) . should . equal ( 'index.html' ) ;
52+ utils . getFilenameFromUrl ( 'http://example.com/p/a/t/h/index.html' ) . should . equal ( 'index.html' ) ;
53+ utils . getFilenameFromUrl ( 'http://example.com/index.html?12' ) . should . equal ( 'index.html' ) ;
54+ utils . getFilenameFromUrl ( 'http://example.com/index.html#t?12' ) . should . equal ( 'index.html' ) ;
55+ utils . getFilenameFromUrl ( 'http://example.com/index.html?12#t' ) . should . equal ( 'index.html' ) ;
56+ utils . getFilenameFromUrl ( 'http://example.com/?12_jdlsk' ) . should . equal ( '' ) ;
57+ utils . getFilenameFromUrl ( 'http://example.com/#index.html' ) . should . equal ( '' ) ;
58+ utils . getFilenameFromUrl ( 'http://example.com/' ) . should . equal ( '' ) ;
5959 } ) ;
6060 it ( 'should return unconverted filename if there are no ?,#' , function ( ) {
61- utils . getFilenameFromUrl ( 'index.html' ) . should . equalFileSystemPath ( 'index.html' ) ;
61+ utils . getFilenameFromUrl ( 'index.html' ) . should . equal ( 'index.html' ) ;
62+ } ) ;
63+ it ( 'should decode escaped chars' , function ( ) {
64+ utils . getFilenameFromUrl ( 'https://example.co/logo-mobile%20(1).svg?q=650' ) . should . equal ( 'logo-mobile (1).svg' ) ;
6265 } ) ;
6366 } ) ;
6467
6568 describe ( '#getFilepathFromUrl' , function ( ) {
6669 it ( 'should return empty sting if url has no pathname' , function ( ) {
67- utils . getFilepathFromUrl ( 'http://example.com' ) . should . be . empty ( ) ;
68- utils . getFilepathFromUrl ( 'http://example.com/' ) . should . be . empty ( ) ;
69- utils . getFilepathFromUrl ( 'http://example.com?' ) . should . be . empty ( ) ;
70- utils . getFilepathFromUrl ( 'http://example.com?abc=3' ) . should . be . empty ( ) ;
71- utils . getFilepathFromUrl ( 'http://example.com#' ) . should . be . empty ( ) ;
72- utils . getFilepathFromUrl ( 'http://example.com#test' ) . should . be . empty ( ) ;
70+ utils . getFilepathFromUrl ( 'http://example.com' ) . should . equal ( '' ) ;
71+ utils . getFilepathFromUrl ( 'http://example.com/' ) . should . equal ( '' ) ;
72+ utils . getFilepathFromUrl ( 'http://example.com?' ) . should . equal ( '' ) ;
73+ utils . getFilepathFromUrl ( 'http://example.com?abc=3' ) . should . equal ( '' ) ;
74+ utils . getFilepathFromUrl ( 'http://example.com#' ) . should . equal ( '' ) ;
75+ utils . getFilepathFromUrl ( 'http://example.com#test' ) . should . equal ( '' ) ;
7376 } ) ;
7477 it ( 'should return path if url has pathname' , function ( ) {
7578 utils . getFilepathFromUrl ( 'http://example.com/some/path' ) . should . equal ( 'some/path' ) ;
@@ -81,6 +84,13 @@ describe('Utils', function () {
8184 utils . getFilepathFromUrl ( 'http://example.com/some/path/' ) . should . equal ( 'some/path' ) ;
8285 utils . getFilepathFromUrl ( 'http://example.com/some/path/file.css/' ) . should . equal ( 'some/path/file.css' ) ;
8386 } ) ;
87+ it ( 'should normalize slashes' , function ( ) {
88+ utils . getFilepathFromUrl ( 'http://example.com///some//path' ) . should . equal ( 'some/path' ) ;
89+ utils . getFilepathFromUrl ( 'http://example.com//////////file.css/' ) . should . equal ( 'file.css' ) ;
90+ } ) ;
91+ it ( 'should decode escaped chars' , function ( ) {
92+ utils . getFilepathFromUrl ( 'https://example.co/logo/logo-mobile%20(1).svg?q=650' ) . should . equal ( 'logo/logo-mobile (1).svg' ) ;
93+ } ) ;
8494 } ) ;
8595
8696 describe ( '#getHashFromUrl' , function ( ) {
0 commit comments