@@ -69,7 +69,7 @@ function _stringStream(
6969) : Writable {
7070 if ( options ?. _useHtmlParser2 ) {
7171 const parser = htmlparser2 . createDocumentStream (
72- ( err , document ) => cb ( err , load ( document ) ) ,
72+ ( err , document ) => cb ( err , load ( document , options ) ) ,
7373 options ,
7474 ) ;
7575
@@ -99,7 +99,7 @@ function _stringStream(
9999
100100 const stream = new Parse5Stream ( options ) ;
101101
102- finished ( stream , ( err ) => cb ( err , load ( stream . document ) ) ) ;
102+ finished ( stream , ( err ) => cb ( err , load ( stream . document , options ) ) ) ;
103103
104104 return stream ;
105105}
@@ -231,7 +231,7 @@ export async function fromURL(
231231 } ;
232232
233233 const promise = new Promise < CheerioAPI > ( ( resolve , reject ) => {
234- undiciStream = new undici . Client ( url )
234+ undiciStream = new undici . Client ( urlObject . origin )
235235 . compose ( undici . interceptors . redirect ( { maxRedirections : 5 } ) )
236236 . stream ( streamOptions , ( res ) => {
237237 if ( res . statusCode < 200 || res . statusCode >= 300 ) {
@@ -272,13 +272,14 @@ export async function fromURL(
272272 }
273273 | undefined
274274 ) ?. history ;
275+ // Set the `baseURI` to the final URL.
276+ const baseURI = history ? history [ history . length - 1 ] : urlObject ;
275277
276- const opts = {
278+ const opts : DecodeStreamOptions = {
277279 encoding,
278280 // Set XML mode based on the MIME type.
279281 xmlMode : mimeType . isXML ( ) ,
280- // Set the `baseURL` to the final URL.
281- baseURL : history ? history [ history . length - 1 ] : url ,
282+ baseURI,
282283 ...cheerioOptions ,
283284 } ;
284285
0 commit comments