Throw error when noteId is empty

Signed-off-by: Tamotsu Takahashi <ttakah+github@gmail.com>
This commit is contained in:
TAKAHASHI Tamotsu 2022-10-14 15:31:53 +09:00 committed by David Mehren
parent 5704ad9c3b
commit 2db114fbff

View file

@ -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. // 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 url = new URL(request.url, 'https://example.org');
const noteId = url.searchParams.get('noteId'); const noteId = url.searchParams.get('noteId');
if (noteId === null) { if (noteId === null || noteId === '') {
throw new Error("Path doesn't contain parameter noteId"); throw new Error(`Path doesn't contain parameter noteId: ${request.url}`);
} else { } else {
return noteId; return noteId;
} }