|
|
@@ -77,6 +77,15 @@ export class TemplateSrv {
|
|
|
return '(' + quotedValues.join(' OR ') + ')';
|
|
|
}
|
|
|
|
|
|
+ // encode string according to RFC 3986; in contrast to encodeURIComponent()
|
|
|
+ // also the sub-delims "!", "'", "(", ")" and "*" are encoded;
|
|
|
+ // unicode handling uses UTF-8 as in ECMA-262.
|
|
|
+ encodeURIComponentStrict(str) {
|
|
|
+ return encodeURIComponent(str).replace(/[!'()*]/g, (c) => {
|
|
|
+ return '%' + c.charCodeAt(0).toString(16).toUpperCase();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
formatValue(value, format, variable) {
|
|
|
// for some scopedVars there is no variable
|
|
|
variable = variable || {};
|
|
|
@@ -118,6 +127,13 @@ export class TemplateSrv {
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
+ case 'percentencode': {
|
|
|
+ // like glob, but url escaped
|
|
|
+ if (_.isArray(value)) {
|
|
|
+ return this.encodeURIComponentStrict('{' + value.join(',') + '}');
|
|
|
+ }
|
|
|
+ return this.encodeURIComponentStrict(value);
|
|
|
+ }
|
|
|
default: {
|
|
|
if (_.isArray(value)) {
|
|
|
return '{' + value.join(',') + '}';
|