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

Function encodeVars

extensions/amp-analytics/0.1/variables.js:514–525  ·  view source on GitHub ↗
(raw)

Source from the content-addressed store, hash-verified

512 * @return {string} The encoded value.
513 */
514export function encodeVars(raw) {
515 if (raw == null) {
516 return '';
517 }
518
519 if (isArray(raw)) {
520 return raw.map(encodeVars).join(',');
521 }
522 // Separate out names and arguments from the value and encode the value.
523 const {argList, name} = getNameArgs(String(raw));
524 return encodeURIComponent(name) + argList;
525}
526
527/**
528 * Returns an array containing two values: name and args parsed from the key.

Callers 2

test-variables.jsFile · 0.90
expandTemplateMethod · 0.85

Calls 3

isArrayFunction · 0.85
getNameArgsFunction · 0.85
StringFunction · 0.50

Tested by

no test coverage detected