dont imply required websocket fix #830

This commit is contained in:
keyan 2024-02-14 11:53:41 -06:00
parent 2587483bbe
commit e57671ba9b
1 changed files with 3 additions and 4 deletions

View File

@ -72,11 +72,10 @@ addMethod(string, 'ws', function (schemas, msg = 'invalid websocket') {
name: 'ws',
message: msg,
test: value => {
if (!value) return true
if (typeof value === 'undefined') return true
try {
// eslint-disable-next-line no-new
new URL(value)
return true
const url = new URL(value)
return url.protocol === 'ws:' || url.protocol === 'wss:'
} catch (e) {
return false
}