From: Ardis Lu Date: Wed, 2 Apr 2025 05:05:37 +0000 (-0700) Subject: Handle case where query param is blank X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=0e385852f846d8fae84e78491cb060c64496559e;p=utf-8-visualizer Handle case where query param is blank --- 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 => {