We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 2bf5bbf + c98ece1 commit 07745edCopy full SHA for 07745ed
index.ts
@@ -432,7 +432,13 @@ export async function getLinkPreview(
432
fetchOptions.redirect === `manual` &&
433
options?.handleRedirects
434
) {
435
- const forwardedUrl = response.headers.get(`location`) || ``;
+ const locationHeader = response.headers.get(`location`) || ``;
436
+ const isAbsoluteURI = locationHeader.startsWith('http://') || locationHeader.startsWith('https://');
437
+
438
+ // Resolve the URL, handling both absolute and relative URLs
439
+ const forwardedUrl = isAbsoluteURI
440
+ ? locationHeader
441
+ : urlObj.resolve(fetchUrl, locationHeader);
442
443
if (!options.handleRedirects(fetchUrl, forwardedUrl)) {
444
throw new Error(`link-preview-js could not handle redirect`);
0 commit comments