-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
Awesome! I need this as well. |
} | ||
|
||
/** | ||
* @return {!RegExpr} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RegExp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
LGTM |
const expr = this.getExpr_(); | ||
return url.replace(expr, (match, name) => { | ||
let val = this.replacements_[name](opt_data); | ||
if (!val && val !== 0) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, 👍
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added docs right there.
LGTM |
UrlReplacements refactoring for amp-pixel and amp-list
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