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

Introduce expandStringAsync and expandStringSync in url-replacement #6323

Merged
merged 2 commits into from Nov 24, 2016

Conversation

mkhatib
Copy link
Contributor

@mkhatib mkhatib commented Nov 23, 2016

Follow up to #6257

Related to: #6130 and #5654

@@ -390,6 +390,19 @@ var forbiddenTerms = {
'src/service/url-replacements-impl.js',
]
},
'expandStringSync\\W': {
Copy link
Contributor

Choose a reason for hiding this comment

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

These should be in forbiddenTermsSrcInclusive. Also: \\.expandStringSync\\(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do, what is the difference between the forbiddenTermsSrcInclusive and forbiddenTerms?

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Test code is allowed to use it in forbiddenTermsSrcInclusive.

return /** @type {string} */(
this.expand_(url, opt_bindings, opt_collectVars, /* opt_sync */ true,
opt_whiteList));
return /** @type {string} */ (this.expandUrlSync(
Copy link
Contributor

Choose a reason for hiding this comment

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

Useless typecast?

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

* @param {string} url
* @param {!Object<string, *>=} opt_bindings
* @return {!Promise<string>}
*/
expandAsync(url, opt_bindings) {
return /** @type {!Promise<string>} */(this.expand_(url, opt_bindings));
return /** @type {!Promise<string>} */ (
Copy link
Contributor

Choose a reason for hiding this comment

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

Useless typecast?

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

* @return {string}
*/
expandUrlSync(url, opt_bindings, opt_collectVars, opt_whiteList) {
return /** @type {string} */ (
Copy link
Contributor

Choose a reason for hiding this comment

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

Useless typecast?

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

* @return {string}
*/
expandUrlSync(url, opt_bindings, opt_collectVars, opt_whiteList) {
return this.ensureProtocolMatches_(url, /** @type {string} */ (this.expand_(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to do the same for the whole origin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what do you mean, /cc @jridgewell who worked on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I see what you mean, basically ensure that the origin hasn't changed. @jridgewell what was the reasoning behind protecting protocol changes and does it apply to origin changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, if you guys don't mind I'll go ahead and merge this and I opened #6338 for continuing this discussion.

@dvoytenko
Copy link
Contributor

LGTM with one question

@mkhatib mkhatib merged commit c71d9f5 into ampproject:master Nov 24, 2016
@mkhatib mkhatib deleted the url-repl-str branch November 24, 2016 00:49
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.

None yet

3 participants