@@ -141,7 +141,7 @@ async function parseResult (response: Promise<string>, opts: Options): Promise<R
141141 }
142142 }
143143
144- const url = Websites [ opts . website ? opts . website . id : 'www' ]
144+ const iqdb = Websites [ opts . website ? opts . website . id : 'www' ]
145145 let results = $ ( 'div#pages' ) . children ( 'div' ) . map ( ( _ , page ) => {
146146 const rows = $ ( 'tr' , page )
147147 const head = $ ( rows [ 0 ] ) . text ( ) . trim ( ) . toLowerCase ( )
@@ -150,15 +150,18 @@ async function parseResult (response: Promise<string>, opts: Options): Promise<R
150150
151151 const link = $ ( 'a' , rows [ 1 ] )
152152 const image = $ ( 'img' , link )
153- const fixedImageUrl = image . attr ( 'src' ) ! . charAt ( 0 ) === '/' ? url + image . attr ( 'src' ) ! : image . attr ( 'src' ) !
153+ const sourceUrl = $ ( link ) . attr ( 'href' ) !
154+ const imageUrl = image . attr ( 'src' ) !
155+ const fixedSourceUrl = sourceUrl . charAt ( 0 ) === '/' && sourceUrl . charAt ( 1 ) === '/' ? 'http:' + sourceUrl : sourceUrl // Always use http to ensure validity
156+ const fixedImageUrl = imageUrl . charAt ( 0 ) === '/' ? iqdb + imageUrl : imageUrl // fixed iqdb image url
154157 const sources = $ ( rows [ 2 ] ) . text ( ) . split ( ' ' )
155158 const dimensionAndType = $ ( rows [ 3 ] ) . text ( ) . split ( ' ' )
156159 const dimension = dimensionAndType [ 0 ] . split ( '×' )
157160 const similarity = $ ( rows [ 4 ] ) . text ( ) . replace ( 'similarity' , '' ) . replace ( '%' , '' ) . trim ( )
158161 const properties = pickImageProperties ( image . attr ( 'alt' ) ! )
159162 return < Result > {
160163 head,
161- url : $ ( link ) . attr ( 'href' ) ,
164+ url : fixedSourceUrl ,
162165 image : fixedImageUrl ,
163166 sources,
164167 width : parseInt ( dimension [ 0 ] ) ,
0 commit comments