mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Remove redundant decodeURI and fix urls (#28697)
* Remove redundant path URIdecoding * Remove redundant comments
This commit is contained in:
@@ -36,8 +36,7 @@ describe('state functions', () => {
|
||||
});
|
||||
|
||||
it('returns a valid Explore state from URL parameter', () => {
|
||||
const paramValue =
|
||||
'%7B"datasource":"Local","queries":%5B%7B"expr":"metric"%7D%5D,"range":%7B"from":"now-1h","to":"now"%7D%7D';
|
||||
const paramValue = '{"datasource":"Local","queries":[{"expr":"metric"}],"range":{"from":"now-1h","to":"now"}}';
|
||||
expect(parseUrlState(paramValue)).toMatchObject({
|
||||
datasource: 'Local',
|
||||
queries: [{ expr: 'metric' }],
|
||||
@@ -49,9 +48,7 @@ describe('state functions', () => {
|
||||
});
|
||||
|
||||
it('returns a valid Explore state from a compact URL parameter', () => {
|
||||
// ["now-1h","now","Local",{"expr":"metric"},{"ui":[true,true,true,"none"]}]
|
||||
const paramValue =
|
||||
'%5B"now-1h","now","Local",%7B"expr":"metric"%7D,%7B%22ui%22:%5Btrue,true,true,%22none%22%5D%7D%5D';
|
||||
const paramValue = '["now-1h","now","Local",{"expr":"metric"},{"ui":[true,true,true,"none"]}]';
|
||||
expect(parseUrlState(paramValue)).toMatchObject({
|
||||
datasource: 'Local',
|
||||
queries: [{ expr: 'metric' }],
|
||||
@@ -63,9 +60,8 @@ describe('state functions', () => {
|
||||
});
|
||||
|
||||
it('should return queries if queryType is present in the url', () => {
|
||||
// ["now-1h","now","x-ray-datasource",{"queryType":"getTraceSummaries"},{"ui":[true,true,true,"none"]}]
|
||||
const paramValue =
|
||||
'%5B"now-1h","now","x-ray-datasource",%7B"queryType":"getTraceSummaries"%7D,%7B%22ui%22:%5Btrue,true,true,%22none%22%5D%7D%5D';
|
||||
'["now-1h","now","x-ray-datasource",{"queryType":"getTraceSummaries"},{"ui":[true,true,true,"none"]}]';
|
||||
expect(parseUrlState(paramValue)).toMatchObject({
|
||||
datasource: 'x-ray-datasource',
|
||||
queries: [{ queryType: 'getTraceSummaries' }],
|
||||
|
@@ -194,7 +194,7 @@ export const safeParseJson = (text?: string): any | undefined => {
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(decodeURI(text));
|
||||
return JSON.parse(text);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
Reference in New Issue
Block a user