From 0e385852f846d8fae84e78491cb060c64496559e Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Tue, 1 Apr 2025 22:05:37 -0700 Subject: [PATCH] Handle case where query param is blank --- script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index d8a88db..ea7274b 100644 --- a/script.js +++ b/script.js @@ -96,7 +96,8 @@ function handleChange(value) { const input = document.querySelector('input'); input.addEventListener('input', e => handleChange(e.target.value)); -input.value = new URL(document.location).searchParams.get('q') ?? '🏴‍☠️'; +const q = new URL(document.location).searchParams.get('q'); +input.value = (q === null || q === '') ? '🏴‍☠️' : q; handleChange(input.value); // Render the default value on first load addEventListener('keyup', e => { -- 2.47.3