Basically I have this really simple javascript that gets the ?user=example query string and if it is not found in the list it does nothing but if it is then it redirects to the according profile.
<script>
var url = window.location.toString();
var query_string = url.split("?");
if (query_string[1] === 'user=example') {
document.location = "https://streety.org/users/example";
}
</script>
Since I have more than one user it would be counterintuitive to put a bunch of if statements for every use so I want to make it so instead it gets the data and puts it into the url https://streety.org/users/ and then tests if the server returns 404 or 200, if 404 then do nothing if 200 then redirect user to that page
How could I do test for a valid page?