From e57671ba9b2fd8ac330d747579e8de1375a6196b Mon Sep 17 00:00:00 2001 From: keyan Date: Wed, 14 Feb 2024 11:53:41 -0600 Subject: [PATCH] dont imply required websocket fix #830 --- lib/validate.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/validate.js b/lib/validate.js index a95d708f..06a72a81 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -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 }