Skip to content

Commit

Permalink
Modify condition to check for pages with meta refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
greyguy21 committed Nov 21, 2023
1 parent fa6c5c7 commit 4b98e36
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions constants/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,17 @@ const requestToUrl = async (url, isNewCustomFlow) => {
const redirectUrl = response.request.res.responseUrl;
res.status = constants.urlCheckStatuses.success.code;

if (redirectUrl != null && !isNewCustomFlow) {
res.url = redirectUrl;
} else {
res.url = url;
}

let modifiedHTML = response.data.replace(/<noscript>[\s\S]*?<\/noscript>/gi, '');
const metaRefreshMatch = /<meta\s+http-equiv="refresh"\s+content="(?:\d+;)?([^"]*)"/i.exec(modifiedHTML);
if (metaRefreshMatch && metaRefreshMatch[1]) {
const hasMetaRefresh = metaRefreshMatch && metaRefreshMatch[1];

if (redirectUrl != null && (hasMetaRefresh || !isNewCustomFlow)) {
res.url = redirectUrl;
} else {
res.url = url;
}

if (hasMetaRefresh) {
const urlOrRelativePath = metaRefreshMatch[1];
if (urlOrRelativePath.includes('URL=')) {
res.url = urlOrRelativePath.split('URL=').pop();
Expand Down

0 comments on commit 4b98e36

Please sign in to comment.