if (errCode == "instance_is_private") {
return res.redirect(`/signup`);
} else {
- return res.send(`404: ${errCode}`);
+ return res.send(`404: ${removeAuthParam(errCode)}`);
}
}
`);
} catch (err) {
console.error(err);
- return res.send(`404: ${err}`);
+ return res.send(`404: ${removeAuthParam(err)}`);
}
});
console.info("Interrupted");
process.exit(0);
});
+
+function removeAuthParam(err: any): string {
+ return removeParam(err.toString(), "auth");
+}
+
+function removeParam(url: string, parameter: string): string {
+ return url
+ .replace(new RegExp("[?&]" + parameter + "=[^&#]*(#.*)?$"), "$1")
+ .replace(new RegExp("([?&])" + parameter + "=[^&]*&"), "$1");
+}