File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,10 @@ Scraper.prototype = {
6060
6161 var parts = url . split ( "/" ) ;
6262 var filename = parts [ parts . length - 1 ] ;
63- filename = filename . replace ( / \? / g, "%3F" ) ;
64- filename = filename . replace ( / = / g, "%3D" ) ;
65- filename = filename . replace ( / & / g, "%26" ) ;
63+ filename = filename . replace ( / \? / g, "" ) ;
64+ if ( filename . length > 130 ) {
65+ filename = filename . substr ( 0 , 130 ) ;
66+ }
6667 return filename ;
6768 } ,
6869
Original file line number Diff line number Diff line change @@ -203,7 +203,18 @@ describe("Scraper", function () {
203203 it ( "should extract filename from image url with query string" , function ( ) {
204204
205205 var image = Scraper . prototype . getFileFilename ( "http://example.com/image.jpg?a=1&b=2" ) ;
206- expect ( image ) . toEqual ( "image.jpg%3Fa%3D1%26b%3D2" ) ;
206+ expect ( image ) . toEqual ( "image.jpga=1&b=2" ) ;
207+ } ) ;
208+
209+ it ( "should shorten image file name to 143 symbols" , function ( ) {
210+
211+ // ext4 max is 254
212+ // ntfs max is 256
213+ // ecryptfs 143
214+ // web scraper allows only 130
215+
216+ var image = Scraper . prototype . getFileFilename ( "http://example.com/012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" ) ;
217+ expect ( image ) . toEqual ( "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" ) ;
207218 } ) ;
208219
209220 it ( "should extract filename from image url without http://" , function ( ) {
You can’t perform that action at this time.
0 commit comments