Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
bde4b76c
Commit
bde4b76c
authored
Jan 22, 2019
by
Benjamin Schweizer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
based on encodeURIComponent() using strict RFC 3986 sub-delims
parent
8a09d847
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
8 deletions
+10
-8
docs/sources/reference/templating.md
+1
-1
public/app/features/templating/specs/template_srv.test.ts
+1
-1
public/app/features/templating/template_srv.ts
+8
-6
No files found.
docs/sources/reference/templating.md
View file @
bde4b76c
...
...
@@ -52,7 +52,7 @@ Filter Option | Example | Raw | Interpolated | Description
`csv`
| ${servers:csv} |
`'test1', 'test2'`
|
`test1,test2`
| Formats multi-value variable as a comma-separated string
`distributed`
| ${servers:distributed} |
`'test1', 'test2'`
|
`test1,servers=test2`
| Formats multi-value variable in custom format for OpenTSDB.
`lucene`
| ${servers:lucene} |
`'test', 'test2'`
|
`("test" OR "test2")`
| Formats multi-value variable as a lucene expression.
`percentencode`
| ${servers:percentencode} |
`'foo()bar BAZ', 'test2'`
|
`{foo%28%29bar%20BAZ%2Ctest2}`
| Formats multi-value variable into a glob, percent-e
scaped
`percentencode`
| ${servers:percentencode} |
`'foo()bar BAZ', 'test2'`
|
`{foo%28%29bar%20BAZ%2Ctest2}`
| Formats multi-value variable into a glob, percent-e
ncoded.
Test the formatting options on the
[
Grafana Play site
](
http://play.grafana.org/d/cJtIfcWiz/template-variable-formatting-options?orgId=1
)
.
...
...
public/app/features/templating/specs/template_srv.test.ts
View file @
bde4b76c
...
...
@@ -277,7 +277,7 @@ describe('templateSrv', () => {
it
(
'multi value and percentencode format should render percent-encoded string'
,
()
=>
{
const
result
=
_templateSrv
.
formatValue
([
'foo()bar BAZ'
,
'test2'
],
'percentencode'
);
expect
(
result
).
toBe
(
'%7
bfoo%28%29bar%20BAZ%2ctest2%7d
'
);
expect
(
result
).
toBe
(
'%7
Bfoo%28%29bar%20BAZ%2Ctest2%7D
'
);
});
it
(
'slash should be properly escaped in regex format'
,
()
=>
{
...
...
public/app/features/templating/template_srv.ts
View file @
bde4b76c
...
...
@@ -77,10 +77,12 @@ 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
);
// 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
();
});
}
...
...
@@ -128,9 +130,9 @@ export class TemplateSrv {
case
'percentencode'
:
{
// like glob, but url escaped
if
(
_
.
isArray
(
value
))
{
return
this
.
encodeURI
QueryValue
(
'{'
+
value
.
join
(
','
)
+
'}'
);
return
this
.
encodeURI
ComponentStrict
(
'{'
+
value
.
join
(
','
)
+
'}'
);
}
return
this
.
encodeURI
QueryValue
(
value
);
return
this
.
encodeURI
ComponentStrict
(
value
);
}
default
:
{
if
(
_
.
isArray
(
value
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment