Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
cramforce committed Oct 28, 2016
1 parent 1eda5bd commit b7f7f2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
16 changes: 11 additions & 5 deletions src/service/document-info-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ export class DocInfo {
if (this.info_) {
return this.info_;
}

const url = this.ampdoc_.getUrl();
const ampdoc = this.ampdoc_;
const url = ampdoc.getUrl();
const sourceUrl = getSourceUrl(url);
const rootNode = this.ampdoc_.getRootNode();
const rootNode = ampdoc.getRootNode();
let canonicalUrl = rootNode && rootNode.AMP
&& rootNode.AMP.canonicalUrl;
if (!canonicalUrl) {
Expand All @@ -73,8 +73,14 @@ export class DocInfo {
? parseUrl(canonicalTag.href).href
: sourceUrl;
}
const pageViewId = getPageViewId(this.ampdoc_.win);
return this.info_ = {url, sourceUrl, canonicalUrl, pageViewId};
const pageViewId = getPageViewId(ampdoc.win);
return this.info_ = {
get sourceUrl() {
return getSourceUrl(ampdoc.getUrl());
},
canonicalUrl,
pageViewId,
};
}
}

Expand Down
3 changes: 1 addition & 2 deletions test/functional/test-document-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ describe('document-info', () => {
win.document.defaultView = win;
installDocService(win, true);
installDocumentInfoServiceForDoc(win.document);
expect(documentInfoForDoc(win.document).url).to.equal(
'https://cdn.ampproject.org/v/www.origin.com/foo/?f=0');
expect(documentInfoForDoc(win.document).sourceUrl).to.equal(
'http://www.origin.com/foo/?f=0');
});
Expand All @@ -88,6 +86,7 @@ describe('document-info', () => {
};
win.document.defaultView = win;
installDocService(win, true);
installDocumentInfoServiceForDoc(win.document);
expect(documentInfoForDoc(win.document).sourceUrl).to.equal(
'http://www.origin.com/foo/?f=0');
win.location.href = 'https://cdn.ampproject.org/v/www.origin.com/foo/?f=1';
Expand Down

0 comments on commit b7f7f2c

Please sign in to comment.