Skip to content

Commit

Permalink
adding expand url export
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Jun 14, 2023
1 parent 93c8ee7 commit 3299938
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,22 @@

const followRedirect = require("./follow-redirect-url");

exports.expandUrl = async function(url) {
let resolvedUrlList;

resolvedUrlList = await followRedirect.startFollowing(url, {
ignoreSslErrors: true,
});

const lastUrlHop = resolvedUrlList[resolvedUrlList.length - 1];

if(lastUrlHop.error) {
return [false, lastUrlHop]
}

const resolvedUrl = resolvedUrlList[resolvedUrlList.length - 1].url;

return [true, resolvedUrl];
}

exports.startFollowing = followRedirect.startFollowing;

0 comments on commit 3299938

Please sign in to comment.