mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
replaced escape() call, renamed formatter to be more expressive
This commit is contained in:
@@ -83,6 +83,13 @@ export class TemplateSrv {
|
||||
return '(' + quotedValues.join(' OR ') + ')';
|
||||
}
|
||||
|
||||
// like encodeURIComponent() but for all characters except alpha-numerics
|
||||
encodeURIQueryValue(str) {
|
||||
return str.replace(/[^a-z0-9]/gi, function(c) {
|
||||
return '%' + c.charCodeAt(0).toString(16);
|
||||
});
|
||||
}
|
||||
|
||||
formatValue(value, format, variable) {
|
||||
// for some scopedVars there is no variable
|
||||
variable = variable || {};
|
||||
@@ -124,12 +131,12 @@ export class TemplateSrv {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
case 'urlescape': {
|
||||
case 'percentencode': {
|
||||
// like glob, but url escaped
|
||||
if (_.isArray(value)) {
|
||||
return escape('{' + value.join(',') + '}');
|
||||
return this.encodeURIQueryValue('{' + value.join(',') + '}');
|
||||
}
|
||||
return escape(value);
|
||||
return this.encodeURIQueryValue(value);
|
||||
}
|
||||
default: {
|
||||
if (_.isArray(value)) {
|
||||
|
||||
Reference in New Issue
Block a user