Skip to content

Commit

Permalink
Restrict the number of global replacements variable (ampproject#19233)
Browse files Browse the repository at this point in the history
* add test

* address comment
  • Loading branch information
zhouyx authored and Enriqe committed Nov 28, 2018
1 parent bc0ef6a commit 3066eb5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/functional/test-url-replacements.js
Expand Up @@ -185,6 +185,18 @@ describes.sandboxed('UrlReplacements', {}, () => {
return win;
}

it('limit replacement params size', () => {
return getReplacements().then(replacements => {
replacements.getVariableSource().initialize();
const variables =
Object.keys(replacements.getVariableSource().replacements_);
// Restrict the number of replacement params to globalVaraibleSource
// Please consider adding the logic to amp-analytics instead.
// Please contact @lannka or @zhouyx if the test fail.
expect(variables.length).to.equal(69);
});
});

it('should replace RANDOM', () => {
return expandUrlAsync('ord=RANDOM?').then(res => {
expect(res).to.match(/ord=(\d+(\.\d+)?)\?$/);
Expand Down

0 comments on commit 3066eb5

Please sign in to comment.