MCPcopy
hub / github.com/ampproject/amphtml / removeParamsFromSearch

Function removeParamsFromSearch

src/url.js:477–485  ·  view source on GitHub ↗
(urlSearch, paramName)

Source from the content-addressed store, hash-verified

475 * @return {string}
476 */
477export function removeParamsFromSearch(urlSearch, paramName) {
478 // TODO: Accept paramNames as an array.
479 if (!urlSearch || urlSearch == '?') {
480 return '';
481 }
482 const paramRegex = new RegExp(`[?&]${paramName}\\b[^&]*`, 'g');
483 const search = urlSearch.replace(paramRegex, '').replace(/^[?&]/, '');
484 return search ? '?' + search : '';
485}
486
487/**
488 * Returns the source URL of an AMP document for documents served

Callers 3

test-url.jsFile · 0.90
removeLinkerParam_Method · 0.90

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected