Refactor code for check endpoint and update test cases accordingly
This commit is contained in:
1 parent
d1e65f53ba
commit
6715a8b500
2 files changed
+16
-23
No files matched your search
@@ -277,13 +277,8 @@ const createMonitor = async (req, res, next) => {
|
||||
const checkEndpointResolution = async (req, res, next) => {
|
||||
try {
|
||||
let { monitorURL } = req.query;
|
||||
|
||||
// Remove the protocol (http:// or https://) if present
|
||||
monitorURL = monitorURL.replace(/^https?:\/\//, '');
|
||||
// Remove the trailing slash if it exists
|
||||
monitorURL = monitorURL.endsWith('/') ? monitorURL.slice(0, -1) : monitorURL;
|
||||
|
||||
dns.resolve(monitorURL, (error) => {
|
||||
monitorURL = new URL(monitorURL);
|
||||
dns.resolve(monitorURL.hostname, (error) => {
|
||||
if (error) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
|
||||
Reference in new issue
Block a user