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
6f3088ae
Unverified
Commit
6f3088ae
authored
Feb 22, 2021
by
Hugo Häggmark
Committed by
GitHub
Feb 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AdHocVariables: Fixes crash when values are stored as numbers (#31382)
parent
dae5e452
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
2 deletions
+46
-2
public/app/features/variables/adhoc/urlParser.test.ts
+36
-0
public/app/features/variables/adhoc/urlParser.ts
+10
-2
No files found.
public/app/features/variables/adhoc/urlParser.test.ts
View file @
6f3088ae
...
@@ -78,6 +78,42 @@ describe('urlParser', () => {
...
@@ -78,6 +78,42 @@ describe('urlParser', () => {
});
});
});
});
describe
(
'parsing toUrl with filters with number values'
,
()
=>
{
it
(
'then url params should be correct'
,
()
=>
{
const
a
=
({
value
:
1974
,
key
:
'key'
,
operator
:
'='
,
condition
:
''
,
}
as
unknown
)
as
AdHocVariableFilter
;
const
filters
:
AdHocVariableFilter
[]
=
[
a
];
const
expectedA
=
`key|=|1974`
;
const
expected
:
string
[]
=
[
expectedA
];
expect
(
toUrl
(
filters
)).
toEqual
(
expected
);
});
});
describe
(
'parsing toUrl with filters with boolean values'
,
()
=>
{
it
(
'then url params should be correct'
,
()
=>
{
const
a
=
({
value
:
false
,
key
:
'key'
,
operator
:
'='
,
condition
:
''
,
}
as
unknown
)
as
AdHocVariableFilter
;
const
filters
:
AdHocVariableFilter
[]
=
[
a
];
const
expectedA
=
`key|=|false`
;
const
expected
:
string
[]
=
[
expectedA
];
expect
(
toUrl
(
filters
)).
toEqual
(
expected
);
});
});
describe
(
'parsing toFilters with url containing no filters as string'
,
()
=>
{
describe
(
'parsing toFilters with url containing no filters as string'
,
()
=>
{
it
(
'then url params should be correct'
,
()
=>
{
it
(
'then url params should be correct'
,
()
=>
{
const
url
:
UrlQueryValue
=
''
;
const
url
:
UrlQueryValue
=
''
;
...
...
public/app/features/variables/adhoc/urlParser.ts
View file @
6f3088ae
...
@@ -17,11 +17,19 @@ export const toFilters = (value: UrlQueryValue): AdHocVariableFilter[] => {
...
@@ -17,11 +17,19 @@ export const toFilters = (value: UrlQueryValue): AdHocVariableFilter[] => {
};
};
function
escapeDelimiter
(
value
:
string
|
undefined
):
string
{
function
escapeDelimiter
(
value
:
string
|
undefined
):
string
{
return
value
?.
replace
(
/
\|
/g
,
'__gfp__'
)
??
''
;
if
(
value
===
null
||
value
===
undefined
)
{
return
''
;
}
return
/
\|
/g
[
Symbol
.
replace
](
value
,
'__gfp__'
);
}
}
function
unescapeDelimiter
(
value
:
string
|
undefined
):
string
{
function
unescapeDelimiter
(
value
:
string
|
undefined
):
string
{
return
value
?.
replace
(
/__gfp__/g
,
'|'
)
??
''
;
if
(
value
===
null
||
value
===
undefined
)
{
return
''
;
}
return
/__gfp__/g
[
Symbol
.
replace
](
value
,
'|'
);
}
}
function
toArray
(
filter
:
AdHocVariableFilter
):
string
[]
{
function
toArray
(
filter
:
AdHocVariableFilter
):
string
[]
{
...
...
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