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

Function compareCurlsDomain

3p/recaptcha.js:218–233  ·  view source on GitHub ↗

* Function to compare curls domains with the passed subdomain * and window * @param {Window} win * @param {string} curlsSubdomain * @param {string} origin * @return {!Promise}

(win, curlsSubdomain, origin)

Source from the content-addressed store, hash-verified

216 * @return {!Promise}
217 */
218function compareCurlsDomain(win, curlsSubdomain, origin) {
219 // Get the hostname after the culrs subdomain of the current iframe window
220 const locationWithoutCurlsSubdomain = win.location.hostname
221 .split('.')
222 .slice(1)
223 .join('.');
224 const curlsHostname = curlsSubdomain + '.' + locationWithoutCurlsSubdomain;
225
226 if (curlsHostname === win.location.hostname) {
227 return Promise.resolve();
228 }
229
230 return Promise.reject(
231 new Error('Origin domain does not match Iframe src: ' + origin)
232 );
233}

Callers 1

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected