From 36bedc67084a81297c66220409a397f58450d61b Mon Sep 17 00:00:00 2001 From: Yuxuan Zhou Date: Mon, 12 Nov 2018 08:50:48 -0800 Subject: [PATCH] Restrict the number of global replacements variable (#19233) * add test * address comment --- test/functional/test-url-replacements.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/functional/test-url-replacements.js b/test/functional/test-url-replacements.js index a7003ab0bac6..16d6771be6c6 100644 --- a/test/functional/test-url-replacements.js +++ b/test/functional/test-url-replacements.js @@ -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+)?)\?$/);