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', name: 'ws',
message: msg, message: msg,
test: value => { test: value => {
if (!value) return true if (typeof value === 'undefined') return true
try { try {
// eslint-disable-next-line no-new const url = new URL(value)
new URL(value) return url.protocol === 'ws:' || url.protocol === 'wss:'
return true
} catch (e) { } catch (e) {
return false return false
} }