File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
import cheerio from "cheerio" ;
2
2
import { fetch } from "cross-fetch" ;
3
- import AbortController from "abort-controller" ;
3
+ import AbortControllerPolyfill from "abort-controller" ;
4
4
import urlObj from "url" ;
5
5
import { CONSTANTS } from "./constants" ;
6
6
@@ -404,7 +404,7 @@ export async function getLinkPreview(
404
404
}
405
405
406
406
const timeout = options ?. timeout ?? 3000 ; // 3 second timeout default
407
- const controller = new AbortController ( ) ;
407
+ const controller = createAbortController ( ) ;
408
408
const timeoutCounter = setTimeout ( ( ) => controller . abort ( ) , timeout ) ;
409
409
410
410
const fetchOptions = {
@@ -488,3 +488,10 @@ export async function getPreviewFromContent(
488
488
489
489
return parseResponse ( response , options ) ;
490
490
}
491
+
492
+
493
+ function createAbortController ( ) : AbortController | AbortControllerPolyfill {
494
+ return typeof AbortController == 'undefined'
495
+ ? new AbortControllerPolyfill ( )
496
+ : new AbortController ( ) ;
497
+ }
You can’t perform that action at this time.
0 commit comments