Skip to content

Commit

Permalink
other than 200 would kill the browser
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberRoute committed Feb 12, 2024
1 parent 8b84a00 commit 667a714
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions static/js/fetchurls.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ function fetchUrls() {
if (this.status === 200) {
// Parse JSON response
const data = JSON.parse(this.responseText);

// Get container element
const container = document.getElementById("container");
var bar = document.querySelector(".progress-bar");
Expand All @@ -17,20 +16,10 @@ function fetchUrls() {
bar.style.width = url.progress + "%";
speedElement.innerText = url.data;
bar.innerText = url.progress.toFixed(0) + "%";
if (url.status === 200 || url.status === 301 || url.status === 302) {
if (url.status === 200) {
let urlDisplay;
if (url.status === 301) {
// For 301 status code, use redirectpath
urlDisplay = `<p>${url.id} <a href="${url.path}" target="_blank">${url.path}</a> - <span style="color: orange;">REDIRECTS TO:</span> <a href="${url.redirectpath}" target="_blank">${url.redirectpath}</a> - <span style="color: green;"> http code: ${url.status} progress: ${url.progress}% ${url.data}</span></p>`;
} else if (url.status === 302) {
// For 302 status code, concatenate path and redirectpath
let targetPath = url.redirectpath ? url.path + url.redirectpath : url.path;
urlDisplay = `<p>${url.id} <a href="${url.path}" target="_blank">${url.path}</a> - <span style="color: orange;">REDIRECTS TO:</span> <a href="${targetPath}" target="_blank">${targetPath}</a> - <span style="color: green;"> http code: ${url.status} progress: ${url.progress}% ${url.data}</span></p>`;
} else {
// For other status codes (200), use the original path
urlDisplay = `<p>${url.id} <a href="${url.path}" target="_blank">${url.path}</a> - <span style="color: green;"> http code: ${url.status} progress: ${url.progress}% ${url.data}</span></p>`;
}

// For other status codes (200), use the original path
urlDisplay = `<p>${url.id} <a href="${url.path}" target="_blank">${url.path}</a> - <span style="color: green;"> http code: ${url.status} progress: ${url.progress}% ${url.data}</span></p>`;
container.innerHTML += urlDisplay;
}
});
Expand Down

0 comments on commit 667a714

Please sign in to comment.