Follow up to 'Add enabledExperiments to soy template'
Issue:
At present state adding experimental flags results in the following
line being added to the '<script>' section of header:
window.ENABLED_EXPERIMENTS = JSON.parse(["flag"])
and JSON.parse fails with the following error:
Uncaught SyntaxError: Unexpected token l in JSON at position 1
at JSON.parse (<anonymous>)
at <anonymous>:1:6
Solution:
Turn the sanitized object toString() so that it results in JSON-parsable
string:
window.ENABLED_EXPERIMENTS = JSON.parse('\x5b\x22flag\x22\x5d')
Change-Id: Ida7e8faa6679880a2204489fbf604fee27ae2cd0
This commit is contained in:
@@ -125,7 +125,7 @@ public class IndexHtmlUtil {
|
||||
|
||||
Set<String> enabledExperiments = experimentData(urlParameterMap);
|
||||
if (!enabledExperiments.isEmpty()) {
|
||||
data.put("enabledExperiments", serializeObject(GSON, enabledExperiments));
|
||||
data.put("enabledExperiments", serializeObject(GSON, enabledExperiments).toString());
|
||||
}
|
||||
return data.build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user