* 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)
| 216 | * @return {!Promise} |
| 217 | */ |
| 218 | function 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 | } |
no test coverage detected