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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰Linker: check for empty param values #19369

Merged
merged 1 commit into from Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion extensions/amp-analytics/0.1/linker-manager.js
Expand Up @@ -262,7 +262,9 @@ export class LinkerManager {
if (this.isDomainMatch_(hostname, domains)) {
const linkerValue = createLinker(/* version */ '1',
this.resolvedIds_[name]);
el.href = addParamToUrl(href, name, linkerValue);
if (linkerValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand you want the logic goes to createLinker and I agree this looks good now.
But depending on if we want to support wildcard domain matching, I think it may worth moving the check before the domain match check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. I will keep this in mind when we add this feature.

el.href = addParamToUrl(href, name, linkerValue);
}
}
}

Expand Down
21 changes: 21 additions & 0 deletions extensions/amp-analytics/0.1/test/test-linker-manager.js
Expand Up @@ -187,6 +187,27 @@ describes.realWin('Linker Manager', {amp: true}, env => {
});
});

it('should not add params where linker value is empty', () => {
const config = {
linkers: {
enabled: true,
proxyOnly: false,
testLinker1: {
ids: {
gclid: '',
},
},
},
};

return new LinkerManager(ampdoc, config, null).init().then(() => {
expect(handlers.length).to.equal(1);
expect(clickAnchor('https://www.source.com/dest?a=1')).to.equal(
'https://www.source.com/dest?a=1'
);
});
});

it('should generate a param valid for ingestion 5 min later', () => {
const clock = sandbox.useFakeTimers(1533329483292);
sandbox.stub(Date.prototype, 'getTimezoneOffset').returns(420);
Expand Down