MCPcopy Create free account
hub / github.com/ampproject/amphtml / addQueryParam

Function addQueryParam

third_party/subscriptions-project/swg.js:5388–5403  ·  view source on GitHub ↗

* Adds a parameter to a query string. * @param {string} url * @param {string} param * @param {string} value * @return {string}

(url, param, value)

Source from the content-addressed store, hash-verified

5386 * @return {string}
5387 */
5388function addQueryParam(url, param, value) {
5389 const queryIndex = url.indexOf('?');
5390 const fragmentIndex = url.indexOf('#');
5391 let fragment = '';
5392 if (fragmentIndex != -1) {
5393 fragment = url.substring(fragmentIndex);
5394 url = url.substring(0, fragmentIndex);
5395 }
5396 if (queryIndex == -1) {
5397 url += '?';
5398 } else if (queryIndex < url.length - 1) {
5399 url += '&';
5400 }
5401 url += encodeURIComponent(param) + '=' + encodeURIComponent(value);
5402 return url + fragment;
5403}
5404
5405/**
5406 * @param {!../proto/api_messages.Message} message

Callers 10

serviceUrlFunction · 0.70
feUrlFunction · 0.70
feCachedFunction · 0.70
openIframeMethod · 0.70
fetch_Method · 0.70
addDevModeParamsToUrlFunction · 0.70
propensityUrl_Method · 0.70
sendSubscriptionStateMethod · 0.70
sendEvent_Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected