Skip to content

Commit

Permalink
Bug fix on visit mode getting redirected
Browse files Browse the repository at this point in the history
  • Loading branch information
PRO-2684 committed Jun 15, 2024
1 parent 7306ff9 commit f1084c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions purlfy.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ class Purlfy extends EventTarget {
logFunc("Error visiting URL:", e);
break;
}
const redirected = r.url !== urlObj.href;
const redirected = r.status >= 300 && r.status < 400 && r.headers.has("location");
if (redirected) {
logFunc("Visit mode, but got redirected to:", r.url);
urlObj = new URL(r.url, urlObj.href);
urlObj = new URL(r.headers.get("location"), urlObj.href);
} else {
const dest = Purlfy.#applyActs(html, rule.acts ?? ["regex:https?:\/\/.(?:www\.)?[-a-zA-Z0-9@%._\+~#=]{2,256}\.[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?!&\/\/=]*)"], logFunc);
if (dest && URL.canParse(dest, urlObj.href)) { // Valid URL
Expand Down

0 comments on commit f1084c2

Please sign in to comment.