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

Function extractSingleDocParams

src/service/ampdoc-impl.js:1072–1090  ·  view source on GitHub ↗

* @param {!Window} win * @param {!{[key: string]: string}|undefined} initParams * @return {!{[key: string]: string}}

(win, initParams)

Source from the content-addressed store, hash-verified

1070 * @return {!{[key: string]: string}}
1071 */
1072function extractSingleDocParams(win, initParams) {
1073 const params = map();
1074 if (initParams) {
1075 // The initialization params take the highest precedence.
1076 Object.assign(params, initParams);
1077 } else {
1078 // Params can be passed via iframe hash/name with hash taking precedence.
1079 if (win.name && win.name.indexOf(PARAMS_SENTINEL) == 0) {
1080 Object.assign(
1081 params,
1082 parseQueryString(win.name.substring(PARAMS_SENTINEL.length))
1083 );
1084 }
1085 if (win.location && win.location.hash) {
1086 Object.assign(params, parseQueryString(win.location.hash));
1087 }
1088 }
1089 return params;
1090}
1091
1092/**
1093 * Install the ampdoc service and immediately configure it for either a

Callers 1

constructorMethod · 0.85

Calls 3

mapFunction · 0.90
parseQueryStringFunction · 0.90
assignMethod · 0.80

Tested by

no test coverage detected