Skip to content

Introduce expandStringAsync and expandStringSync in url-replacement#6323

Merged
mkhatib merged 2 commits intoampproject:masterfrom
mkhatib:url-repl-str
Nov 24, 2016
Merged

Introduce expandStringAsync and expandStringSync in url-replacement#6323
mkhatib merged 2 commits intoampproject:masterfrom
mkhatib:url-repl-str

Conversation

@mkhatib
Copy link
Copy Markdown
Contributor

@mkhatib mkhatib commented Nov 23, 2016

Follow up to #6257

Related to: #6130 and #5654

'src/service/url-replacements-impl.js',
]
},
'expandStringSync\\W': {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

*/
expandAsync(url, opt_bindings) {
return /** @type {!Promise<string>} */(this.expand_(url, opt_bindings));
return /** @type {!Promise<string>} */ (
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

3 participants