JSFiddle - React, Tailwind, and code Playground
JavaScript
const url1 = new URL('http://example.com/path/index.html');
const url2 = new URL('http://example.com/path/index.html?');
console.log(url1.search); // => ''
console.log(url2.search); // => ''