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

UrlReplacements refactoring for amp-pixel and amp-list #950

Merged
merged 1 commit into from
Nov 17, 2015

Conversation

dvoytenko
Copy link
Contributor

Both amp-pixel and amp-list (and others in the future) will be able to take advantage of default substitutions and customize for their own needs.

Partial for #657.

/cc @cramforce

@cramforce
Copy link
Member

Awesome! I need this as well.

}

/**
* @return {!RegExpr}
Copy link
Member

Choose a reason for hiding this comment

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

RegExp

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

@cramforce
Copy link
Member

LGTM

const expr = this.getExpr_();
return url.replace(expr, (match, name) => {
let val = this.replacements_[name](opt_data);
if (!val && val !== 0) {
Copy link
Member

Choose a reason for hiding this comment

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

can you explain when it will be 0? or did you mean to check length?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we allow numbers as return values and most other types too. So, I'm special-casing 0 in this case since it's a sensible numeric value for our substitutions.

Copy link
Member

Choose a reason for hiding this comment

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

got it, 👍

Copy link
Member

Choose a reason for hiding this comment

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

is that document anywhere btw?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added docs right there.

@erwinmombay
Copy link
Member

LGTM

dvoytenko added a commit that referenced this pull request Nov 17, 2015
UrlReplacements refactoring for amp-pixel and amp-list
@dvoytenko dvoytenko merged commit 52e1bcf into ampproject:master Nov 17, 2015
@dvoytenko dvoytenko deleted the url-repl branch November 17, 2015 18:57
@mborof mborof mentioned this pull request Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants