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

馃悰Linker: check for empty param values #19369

merged 1 commit into from Nov 19, 2018

Conversation

calebcordry
Copy link
Member

Currently if a pub/vendor is using a config that looks something like this:

linkers: {
  testLinker1: {
    ids: {
      cid: 'QUERY_PARAM(cid)',
    }
  }
}

It is possible that the QUERY_PARAM macro resolves to an empty string, and therefore the linker value will resolve to an empty string. In this case we send a param like testLinker1=. This changes this behavior so that if a param value is empty it will not be appended.

Copy link
Contributor

@torch2424 torch2424 left a comment

Choose a reason for hiding this comment

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

LGTM 馃槃 馃殺

@calebcordry calebcordry merged commit e43a3c9 into ampproject:master Nov 19, 2018
@calebcordry calebcordry deleted the empty-param branch November 19, 2018 19:25
@@ -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.

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

Successfully merging this pull request may close these issues.

None yet

5 participants