]> git.ardis.lu - utf-8-visualizer/commitdiff
Handle case where query param is blank
authorArdis Lu <ardisglu@gmail.com>
Wed, 2 Apr 2025 05:05:37 +0000 (22:05 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 2 Apr 2025 05:05:37 +0000 (22:05 -0700)
script.js

index d8a88dba06b0d325cb1c3ca561219606aa16eede..ea7274b17cb7f2db953bfeb55441d58cb23747d9 100644 (file)
--- 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 => {
This page took 0.035071 seconds and 4 git commands to generate.