camo: support URL encoding option

This commit is contained in:
Calvin Montgomery 2017-07-08 19:21:14 -07:00
parent 54045766f2
commit 486ce04a3e
6 changed files with 56 additions and 4 deletions

View file

@ -4,6 +4,14 @@ class CamoConfig {
if (this.config.server) {
this.config.server = this.config.server.replace(/\/+$/, '');
}
this.validate();
}
validate() {
if (this.config.encoding
&& !~['url', 'hex'].indexOf(this.config.encoding)) {
throw new Error(`Value for key 'encoding' must be either 'url' or 'hex', not '${this.config.encoding}'`);
}
}
isEnabled() {
@ -21,6 +29,10 @@ class CamoConfig {
getWhitelistedDomains() {
return this.config['whitelisted-domains'] || [];
}
getEncoding() {
return this.config.encoding || 'url';
}
}
export { CamoConfig };