From 2db114fbffffd32f9b1869396d10ce13f6bfb0c0 Mon Sep 17 00:00:00 2001 From: TAKAHASHI Tamotsu Date: Fri, 14 Oct 2022 15:31:53 +0900 Subject: [PATCH] Throw error when noteId is empty Signed-off-by: Tamotsu Takahashi --- .../websocket/utils/extract-note-id-from-request-url.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/realtime/websocket/utils/extract-note-id-from-request-url.ts b/src/realtime/websocket/utils/extract-note-id-from-request-url.ts index 9b87f491a..e6abe99c4 100644 --- a/src/realtime/websocket/utils/extract-note-id-from-request-url.ts +++ b/src/realtime/websocket/utils/extract-note-id-from-request-url.ts @@ -20,8 +20,8 @@ export function extractNoteIdFromRequestUrl(request: IncomingMessage): string { // The example.org domain should be safe to use according to RFC 6761 ยง6.5. const url = new URL(request.url, 'https://example.org'); const noteId = url.searchParams.get('noteId'); - if (noteId === null) { - throw new Error("Path doesn't contain parameter noteId"); + if (noteId === null || noteId === '') { + throw new Error(`Path doesn't contain parameter noteId: ${request.url}`); } else { return noteId; }