Refactor code for check endpoint and update test cases accordingly

This commit is contained in:
om-3004 committed 2024-10-17 10:02:01 +05:30
1 parent d1e65f53ba
commit 6715a8b500
2 files changed
+16 -23

No files matched your search

+2 -7
View File
@@ -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,