As `UrlQueryParameterCollection` is deprecated, I suggest to use the [URLSearchParams][1] browser API instead.

Here is my code to **get** value of *search* parameter:

 const url = new URL(window.location.href);
 const params = new URLSearchParams(url.search);
 let searchParam: string;
 params.has('search') ? searchParam = params.get("search") : searchParam = "";

Here is my code to **delete** *search* parameter and update URL:

 const url = new URL(window.location.href);
 const params = new URLSearchParams(url.search);
 if (params.has('search')) {
 params.delete('search');
 window.history.replaceState({}, '', `${location.pathname}?${params}`);
 }

 [1]: https://developers.google.com/web/updates/2016/01/urlsearchparams