From b36e0a5e28daa6b830f7bd8b44b98485281be829 Mon Sep 17 00:00:00 2001 From: streamich Date: Wed, 23 Dec 2020 17:08:23 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20respect=20encoding=20con?= =?UTF-8?q?fig=20setting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../url_drilldown/public/lib/url_drilldown.tsx | 7 ++++++- .../public/drilldowns/url_drilldown/url_template.ts | 12 +++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown.tsx b/x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown.tsx index 360bf70f15032..ffb0687305168 100644 --- a/x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown.tsx +++ b/x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown.tsx @@ -134,7 +134,12 @@ export class UrlDrilldown implements Drilldown { 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; }