fix(monitor): DNS monitor hostname and other monitors URL validations#6577
Conversation
Fixes Issue louislam#6444 Summary: * DNS monitor hostname input will accept wildcard and rejects IP (Valid : *.testdns.co, Invalid : 8.8.8.8) * http, keyword, json-query, websocket, real-browser monitors will not accept wildcard hostnames in URL (Invalid : https://*.testdns.co/status)
CommanderStorm
left a comment
There was a problem hiding this comment.
Nice work, I have a few comments below, but nothing hard to implement.
src/pages/EditMonitor.vue
Outdated
| type="text" | ||
| class="form-control" | ||
| :pattern="`${monitor.type === 'mqtt' ? mqttIpOrHostnameRegexPattern : ipOrHostnameRegexPattern}`" | ||
| :pattern="monitor.type === 'mqtt' ? mqttIpOrHostnameRegexPattern : (monitor.type === 'dns' ? null : ipOrHostnameRegexPattern)" |
There was a problem hiding this comment.
do we still need ipOrHostnameRegexPattern?
I think `validator does the same thing below aready, right?
There was a problem hiding this comment.
Yes. I will remove this regex patten and the function hostNameRegexPattern(mqtt) completely. I will move the validations to isInputValid() method.
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
AnuragEkkati
left a comment
There was a problem hiding this comment.
Provided comments for the review on how I am going to proceed with addressing them.
CommanderStorm
left a comment
There was a problem hiding this comment.
Thanks, nice work on the cleanup 🎉
Thanks for the opportunity. |
|
not a test introduced in your PR, apparently a bit flaky. |

📝 Summary of changes done and why they are done
Used validator library methods to validate hostname and URL for the monitors form validating FQDN and IP (v4 and v6) fields.
Cosmetic changes in the doc-string for hostNameRegexPattern in util-frontend.js
Testing
Valid :
DNS
HTTP/WSS
Invalid :
DNS
HTTP/WSS
📋 Related issues
Dependencies
validator : 13.15.26
AI Usage
I have relied on AI to review my code and let me know if there is any case I missed to cover. I used for a comprehensive list of hostnames and URL patterns to test if the changes work as expected.
LLM : Claude sonnet-4.5
IDE: Cursor AI
📄 Checklist
Please follow this checklist to avoid unnecessary back and forth (click to expand)
📷 Screenshots or Visual Changes
DNSDNSHTTPWSS