Skip to content

Commit

Permalink
feat: 🎸 respect encoding config setting
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Dec 23, 2020
1 parent 4764eaf commit b36e0a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ export class UrlDrilldown implements Drilldown<Config, UrlTrigger, ActionFactory
};

private buildUrl(config: Config, context: ActionContext): string {
const url = urlDrilldownCompileUrl(config.url.template, this.getRuntimeVariables(context));
const doEncode = config.encodeUrl ?? true;
const url = urlDrilldownCompileUrl(
config.url.template,
this.getRuntimeVariables(context),
doEncode
);
return url;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ handlebars.registerHelper('replace', (...args) => {
return String(str).split(searchString).join(valueString);
});

export function compile(url: string, context: object): string {
const template = handlebars.compile(url, { strict: true, noEscape: true });
return encodeURI(template(context));
export function compile(urlTemplate: string, context: object, doEncode: boolean = true): string {
const handlebarsTemplate = handlebars.compile(urlTemplate, { strict: true, noEscape: true });
let url: string = handlebarsTemplate(context);

if (doEncode) {
url = encodeURI(url);
}

return url;
}

0 comments on commit b36e0a5

Please sign in to comment.