Commit f71f03bf by Ivana Huckova Committed by GitHub

Explore: Remove redundant decodeURI and fix urls (#28697)

* Remove redundant path URIdecoding

* Remove redundant comments
parent 87ba1b67
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment