Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Fix quoting and url-encoding #394

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export const getTimeFieldsFromUrl = () => {
const url = unhashUrl(window.location.href);

let [, fromDateString, toDateString] = url.match(timeRangeMatcher);
fromDateString = fromDateString.replace(/[']+/g, '');
fromDateString = fromDateString.replace(/[']+/g, '').replace('%2F','/');
// convert time range to from date format in case time range is relative
const fromDateFormat = dateMath.parse(fromDateString);
toDateString = toDateString.replace(/[']+/g, '');
toDateString = toDateString.replace(/[']+/g, '').replace('%2F','/');
const toDateFormat = dateMath.parse(toDateString);

const timeDuration = moment.duration(
Expand Down Expand Up @@ -128,22 +128,22 @@ export const replaceQueryURL = (pageUrl) => {
// we unhash the url in case Kibana advanced UI setting 'state:storeInSessionStorage' is turned on
const unhashedUrl = new URL(unhashUrl(pageUrl));
let queryUrl = unhashedUrl.pathname + unhashedUrl.hash;
let [, fromDateString, toDateString] = queryUrl.match(timeRangeMatcher);
fromDateString = fromDateString.replace(/[']+/g, '');
let [, fromDateStringMatch, toDateStringMatch] = queryUrl.match(timeRangeMatcher);
fromDateString = fromDateStringMatch.replace(/[']+/g, '').replace('%2F','/');

// convert time range to from date format in case time range is relative
const fromDateFormat = dateMath.parse(fromDateString);
toDateString = toDateString.replace(/[']+/g, '');
toDateString = toDateStringMatch.replace(/[']+/g, '').replace('%2F','/');
const toDateFormat = dateMath.parse(toDateString);

// replace to and from dates with absolute date
queryUrl = queryUrl.replace(
fromDateString,
fromDateStringMatch,
"'" + fromDateFormat.toISOString() + "'"
);
queryUrl = queryUrl.replace(
toDateString + '))',
"'" + toDateFormat.toISOString() + "'))"
toDateStringMatch,
"'" + toDateFormat.toISOString() + "'"
);
return queryUrl;
};
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ export function ReportDetails(props) {
timeRangeMatcher
);

fromDateString = fromDateString.replace(/[']+/g, '');
toDateString = toDateString.replace(/[']+/g, '');
fromDateString = fromDateString.replace(/[']+/g, '').replace('%2F','/');
toDateString = toDateString.replace(/[']+/g, '').replace('%2F','/');

let fromDateParsed = dateMath.parse(fromDateString);
let toDateParsed = dateMath.parse(toDateString);
Expand Down