@@ -10,49 +10,54 @@ var options = { defaultFilename: 'index.html' };
1010describe ( 'FilenameGenerator: bySiteStructure' , function ( ) {
1111 it ( 'should return the normalized relative path of the resource url' , function ( ) {
1212 var r1 = new Resource ( 'http://example.com/some/path/a.png' ) ;
13- bySiteStructureFilenameGenerator ( r1 , options ) . should . equalFileSystemPath ( 'some/path/a.png' ) ;
13+ bySiteStructureFilenameGenerator ( r1 , options ) . should . equalFileSystemPath ( 'example.com/ some/path/a.png' ) ;
1414
1515 var r2 = new Resource ( 'http://example.com/a.png' ) ;
16- bySiteStructureFilenameGenerator ( r2 , options ) . should . equalFileSystemPath ( 'a.png' ) ;
16+ bySiteStructureFilenameGenerator ( r2 , options ) . should . equalFileSystemPath ( 'example.com/ a.png' ) ;
1717
1818 var r3 = new Resource ( 'http://example.com/some/path/../images/a.png' ) ;
19- bySiteStructureFilenameGenerator ( r3 , options ) . should . equalFileSystemPath ( 'some/images/a.png' ) ;
19+ bySiteStructureFilenameGenerator ( r3 , options ) . should . equalFileSystemPath ( 'example.com/some/images/a.png' ) ;
20+ } ) ;
21+
22+ it ( 'should replace the colon, for url with port number' , function ( ) {
23+ var r1 = new Resource ( 'http://example.com:8080/some/path/a.png' ) ;
24+ bySiteStructureFilenameGenerator ( r1 , options ) . should . equalFileSystemPath ( 'example.com_8080/some/path/a.png' ) ;
2025 } ) ;
2126
2227 it ( 'should add the defaultFilename to the path, for html resources without extension' , function ( ) {
2328 var isHtmlMock = sinon . stub ( ) . returns ( true ) ;
2429
2530 var r1 = new Resource ( 'http://example.com/some/path/' ) ;
2631 r1 . isHtml = isHtmlMock ;
27- bySiteStructureFilenameGenerator ( r1 , options ) . should . equalFileSystemPath ( 'some/path/index.html' ) ;
32+ bySiteStructureFilenameGenerator ( r1 , options ) . should . equalFileSystemPath ( 'example.com/ some/path/index.html' ) ;
2833
2934 var r2 = new Resource ( 'http://example.com/some/path' ) ;
3035 r2 . isHtml = isHtmlMock ;
31- bySiteStructureFilenameGenerator ( r2 , options ) . should . equalFileSystemPath ( 'some/path/index.html' ) ;
36+ bySiteStructureFilenameGenerator ( r2 , options ) . should . equalFileSystemPath ( 'example.com/ some/path/index.html' ) ;
3237
3338 var r3 = new Resource ( 'http://example.com' ) ;
3439 r3 . isHtml = isHtmlMock ;
35- bySiteStructureFilenameGenerator ( r3 , options ) . should . equalFileSystemPath ( 'index.html' ) ;
40+ bySiteStructureFilenameGenerator ( r3 , options ) . should . equalFileSystemPath ( 'example.com/ index.html' ) ;
3641 } ) ;
3742
3843 it ( 'should add the defaultFilename to the path, for html resources with wrong extension' , function ( ) {
3944 var isHtmlMock = sinon . stub ( ) . returns ( true ) ;
4045
4146 var r1 = new Resource ( 'http://example.com/some/path/test.com' ) ;
4247 r1 . isHtml = isHtmlMock ;
43- bySiteStructureFilenameGenerator ( r1 , options ) . should . equalFileSystemPath ( 'some/path/test.com/index.html' ) ;
48+ bySiteStructureFilenameGenerator ( r1 , options ) . should . equalFileSystemPath ( 'example.com/ some/path/test.com/index.html' ) ;
4449 } ) ;
4550
4651 it ( 'should normalize to safe relative paths, without ..' , function ( ) {
4752 var r = new Resource ( 'http://example.com/some/path/../../../../images/a.png' ) ;
48- bySiteStructureFilenameGenerator ( r , options ) . should . equalFileSystemPath ( 'images/a.png' ) ;
53+ bySiteStructureFilenameGenerator ( r , options ) . should . equalFileSystemPath ( 'example.com/ images/a.png' ) ;
4954 } ) ;
5055
5156 it ( 'should not replace thrice dot in filenames' , function ( ) {
5257 // if it replaces them we receive 'some/path/../../../../etc/passwd'
5358 // path.resolve('some/path/../../../../etc/passwd'); = '/etc/passwd' => which is not safe
5459 var r = new Resource ( 'http://example.com/some/path/.../.../.../.../etc/passwd' ) ;
55- bySiteStructureFilenameGenerator ( r , options ) . should . equalFileSystemPath ( 'some/path/.../.../.../.../etc/passwd' ) ;
60+ bySiteStructureFilenameGenerator ( r , options ) . should . equalFileSystemPath ( 'example.com/ some/path/.../.../.../.../etc/passwd' ) ;
5661 } ) ;
5762
5863 it ( 'should shorten filename' , function ( ) {
@@ -74,10 +79,10 @@ describe('FilenameGenerator: bySiteStructure', function() {
7479 it ( 'should return decoded filepath' , function ( ) {
7580 var r = new Resource ( 'https://developer.mozilla.org/ru/docs/JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B' ) ;
7681 var filename = bySiteStructureFilenameGenerator ( r , options ) ;
77- filename . should . equalFileSystemPath ( 'ru/docs/JavaScript_шеллы' ) ;
82+ filename . should . equalFileSystemPath ( 'developer.mozilla.org/ ru/docs/JavaScript_шеллы' ) ;
7883
7984 var r2 = new Resource ( 'https://developer.mozilla.org/Hello%20G%C3%BCnter.png' ) ;
8085 var filename2 = bySiteStructureFilenameGenerator ( r2 , options ) ;
81- filename2 . should . equalFileSystemPath ( 'Hello Günter.png' ) ;
86+ filename2 . should . equalFileSystemPath ( 'developer.mozilla.org/ Hello Günter.png' ) ;
8287 } ) ;
8388} ) ;
0 commit comments