Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Created November 22, 2025 18:01
Show Gist options
  • Select an option

  • Save jpluimers/f017d1dd5573d523eba4807b7d233274 to your computer and use it in GitHub Desktop.

Select an option

Save jpluimers/f017d1dd5573d523eba4807b7d233274 to your computer and use it in GitHub Desktop.
Unsuccessful Browser client side HTTP redirect checker
var xhr = new XMLHttpRequest();
xhr.onload = function() {
if (this.status < 400 && this.status >= 300) {
console.log('request redirects to ' + this.getResponseHeader("Location"));
} else {
console.log('request does not redirect');
}
}
xhr.open('HEAD', 'https://t.co/Ui4Wmesq1j', true);
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment