MCPcopy Create free account
hub / github.com/angular/dev-infra / buildMockDispatch

Function buildMockDispatch

github-actions/browserstack/set-browserstack-env.js:11118–11145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11116 return true;
11117 }
11118 if (typeof headers !== "object" || typeof mockDispatch2.headers !== "object") {
11119 return false;
11120 }
11121 for (const [matchHeaderName, matchHeaderValue] of Object.entries(mockDispatch2.headers)) {
11122 const headerValue = getHeaderByName(headers, matchHeaderName);
11123 if (!matchValue(matchHeaderValue, headerValue)) {
11124 return false;
11125 }
11126 }
11127 return true;
11128 }
11129 function safeUrl(path4) {
11130 if (typeof path4 !== "string") {
11131 return path4;
11132 }
11133 const pathSegments = path4.split("?");
11134 if (pathSegments.length !== 2) {
11135 return path4;
11136 }
11137 const qp = new URLSearchParams(pathSegments.pop());
11138 qp.sort();
11139 return [...pathSegments, qp.toString()].join("?");
11140 }
11141 function matchKey(mockDispatch2, { path: path4, method, body, headers }) {
11142 const pathMatch = matchValue(mockDispatch2.path, path4);
11143 const methodMatch = matchValue(mockDispatch2.method, method);
11144 const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
11145 const headersMatch = matchHeaders(mockDispatch2, headers);
11146 return pathMatch && methodMatch && bodyMatch && headersMatch;
11147 }
11148 function getResponseData(data) {

Callers

nothing calls this directly

Calls 1

checkNetConnectFunction · 0.70

Tested by

no test coverage detected