Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not XHR intercept first party (1P) CDN resources #16650

Merged
merged 6 commits into from
Jul 11, 2018
Merged

Do not XHR intercept first party (1P) CDN resources #16650

merged 6 commits into from
Jul 11, 2018

Conversation

alabiaga
Copy link
Contributor

fixes #16601

  • fetch URLs to a AMP HTML CDN will not be xhr intercepted to the viewer.

@alabiaga alabiaga changed the title Do not intercept first party (1P) CDN resources Do not XHR intercept first party (1P) CDN resources Jul 10, 2018
@dreamofabear dreamofabear requested a review from jridgewell July 10, 2018 19:41
@@ -185,7 +187,8 @@ export class Xhr {
}
const viewer = Services.viewerForDoc(this.ampdocSingle_);
const whenFirstVisible = viewer.whenFirstVisible();
if (!viewer.hasCapability('xhrInterceptor')) {
const firstPartyResource = urls.cdnProxyRegex.test(new URL(input).origin);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL is not supported everywhere. Use our helper functions in url.js.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. thanks.

@@ -185,7 +187,9 @@ export class Xhr {
}
const viewer = Services.viewerForDoc(this.ampdocSingle_);
const whenFirstVisible = viewer.whenFirstVisible();
if (!viewer.hasCapability('xhrInterceptor')) {
const firstPartyResource =
urls.cdnProxyRegex.test(parseUrlDeprecated(input).origin);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use isProxyOrigin from src/url.js.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect. Thanks!

@@ -21,7 +21,7 @@ import {fromIterator} from '../utils/array';
import {
getCorsUrl,
getSourceOrigin,
getWinOrigin,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argh. was not intended. reverted.

@codecov-io
Copy link

Codecov Report

Merging #16650 into master will decrease coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master   #16650      +/-   ##
==========================================
- Coverage   78.13%   78.12%   -0.01%     
==========================================
  Files         553      553              
  Lines       40318    40318              
==========================================
- Hits        31503    31500       -3     
- Misses       8815     8818       +3
Flag Coverage Δ
#integration_tests 34.92% <100%> (-0.04%) ⬇️
#unit_tests 77.19% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 30abb19...2f84663. Read the comment docs.

@alabiaga
Copy link
Contributor Author

THANKS!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AMP4EMAIL: Don't proxy XHRs to CDN resources
5 participants