Skip to content

Commit

Permalink
Merge pull request #297 from metrico/dev
Browse files Browse the repository at this point in the history
hotfix: strings escaping
  • Loading branch information
jacovinus authored Mar 8, 2023
2 parents 5ddb821 + d4d770e commit 7b2b435
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,6 @@ export default deepFreeze(
},
linkPatterns: [],
menu: [
{
label: 'About Jaeger',
items: [
{
label: 'GitHub',
url: 'https://github.com/uber/jaeger',
},
{
label: 'Docs',
url: 'http://jaeger.readthedocs.io/en/latest/',
},
{
label: 'Twitter',
url: 'https://twitter.com/JaegerTracing',
},
{
label: 'Discussion Group',
url: 'https://groups.google.com/forum/#!forum/jaeger-tracing',
},
{
label: 'Gitter.im',
url: 'https://gitter.im/jaegertracing/Lobby',
},
{
label: 'Blog',
url: 'https://medium.com/jaegertracing/',
},
],
},
],
search: {
maxLookback: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,4 @@ type ReferenceLinkProps = {
// createFocusSpanLink: (traceId: string, spanId: string) => LinkModel<Field>;
};
export default null
// export default function ReferenceLink(props: ReferenceLinkProps) {
// const { reference, children /* createFocusSpanLink */ } = props;

// // const link = createFocusSpanLink(reference.traceID, reference.spanID);

// return (
// <a
// href={link.href}
// target={link.target}
// rel="noopener noreferrer"
// onClick={
// link.onClick
// ? (event) => {
// event.preventDefault();
// link.onClick!(event);
// }
// : undefined
// }
// >
// {children}
// </a>
// );
// }
7 changes: 4 additions & 3 deletions src/components/LabelBrowser/components/QueryBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ export const QueryBar = (props: any) => {
const ratiointval = Math.round(
intval * Number(window.devicePixelRatio.toFixed(2))
);
querySubmit = query.replace("[$__interval]", `[${ratiointval}s]`);

querySubmit = query.replace(/\[\$__interval\]/, `[${ratiointval}s]`);
customStep = ratiointval;
} else {
querySubmit = query;
Expand Down Expand Up @@ -497,7 +498,7 @@ export const QueryBar = (props: any) => {
};

const saveQuery = (e = []) => {
const queryParams = new URLSearchParams(hash.replace("#", ""));
const queryParams = new URLSearchParams(hash.replace(/#/, ""));
const multiline = e
?.map((text: any) => text.children[0].text)
.join("\n");
Expand Down Expand Up @@ -703,7 +704,7 @@ export const QueryBar = (props: any) => {
intval * Number(window.devicePixelRatio.toFixed(2))
);
querySubmit = queryExpr.replace(
"[$__interval]",
/\[\$__interval\]/,
`[${ratiointval}s]`
);
customStep = ratiointval;
Expand Down
2 changes: 1 addition & 1 deletion src/components/LabelBrowser/components/QuerySetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const QuerySetting = (props:any) => {
props.data.direction
)
useEffect(() => {
const urlParams = new URLSearchParams(hash.replace("#", ""))
const urlParams = new URLSearchParams(hash.replace(/#/, ""))
const urlPanel: any = urlParams.get(name)
const parsedPanel = JSON.parse(decodeURIComponent(urlPanel))
if (parsedPanel?.length > 0) {
Expand Down
18 changes: 11 additions & 7 deletions src/components/LabelBrowser/helpers/querybuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,11 @@ function parseQueryLabels(keyVal: any[], query: string, op: string) {
) {
// values group from existing label
let labelMod = parseLog.addValueToLabel(label, value, true); // use this one for !=
let labelEscaped = new RegExp(`${label}`);
return parseLog
.splitLabels(query)
?.splitLabels(query)
?.join(",")
?.replace(`${label}`, labelMod);
?.replace(labelEscaped, labelMod);
}

if (
Expand All @@ -159,10 +160,11 @@ function parseQueryLabels(keyVal: any[], query: string, op: string) {
) {
// filter value from existing values group from label
const labelMod = parseLog.rmValueFromLabel(label, value);
let labelEscaped = new RegExp(`${label}`);
return parseLog
.splitLabels(query)
.join(",")
.replace(`${label}`, labelMod);
?.splitLabels(query)
?.join(",")
?.replace(labelEscaped, labelMod);
}

if (
Expand Down Expand Up @@ -205,10 +207,11 @@ function parseQueryLabels(keyVal: any[], query: string, op: string) {
) {
// values group from existing label
let labelMod = parseLog.addNonEqValueToLabel(label, value, true); // use this one for !=
let labelScaped = new RegExp(`${label}`)
return parseLog
.splitLabels(query)
?.join(",")
?.replace(`${label}`, labelMod);
?.replace(labelScaped, labelMod);
}
if (
value !== null &&
Expand All @@ -218,10 +221,11 @@ function parseQueryLabels(keyVal: any[], query: string, op: string) {
) {
// filter value from existing values group from label
const labelMod = parseLog.rmNonEqValueFromLabel(label, value);
let labelScaped = new RegExp(`${label}`)
return parseLog
.splitLabels(query)
.join(",")
.replace(`${label}`, labelMod);
.replace(labelScaped, labelMod);
}
if (
label?.includes("!=") &&
Expand Down
2 changes: 1 addition & 1 deletion src/components/Panel/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function Panel(props: any) {
const { hash } = useLocation();

useEffect(() => {
const params = new URLSearchParams(hash.replace("#", ""));
const params = new URLSearchParams(hash.replace(/#/, ""));
const panelUrlData = params.get(name);
let panelQueries = [];
if (panelUrlData) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/QueryTypeBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default function QueryTypeBar(props:any) {
);

useEffect(() => {
const urlParams = new URLSearchParams(hash.replace("#", ""));
const urlParams = new URLSearchParams(hash.replace(/#/, ""));
const urlPanel:any = urlParams.get(name);

const parsedPanel = JSON.parse(decodeURIComponent(urlPanel)||'[]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default function CopyLinkButton() {
function copyLink(e: any) {
e.preventDefault();
setSubmitted();
const params = new URLSearchParams(hash.replace("#", ""));
const params = new URLSearchParams(hash.replace(/#/, ""));
params.set("label", label);
const locationWithLabel = new URL(window.location.href);
locationWithLabel.hash = `#${params.toString()}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const handleCopyLink = (
) => {
e.preventDefault();
setSubmitted();
const params = new URLSearchParams(hash.replace("#", ""));
const params = new URLSearchParams(hash.replace(/#/, ""));
params.set("label", label);
const locationWithLabel = new URL(window.location.href);
locationWithLabel.hash = `#${params.toString()}`;
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/UpdateStateFromQueryParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function UpdateStateFromQueryParams() {

const { hash } = useLocation();
useEffect(() => {
const urlFromHash = new URLSearchParams(hash.replace("#", ""));
const urlFromHash = new URLSearchParams(hash.replace(/#/, ""));
// !if there is some params set them first on UI

if (hash.length > 0) {
Expand Down Expand Up @@ -208,7 +208,7 @@ export function UpdateStateFromQueryParams() {

useEffect(() => {
if (hash.length > 0) {
const paramsFromHash = new URLSearchParams(hash.replace("#", ""));
const paramsFromHash = new URLSearchParams(hash.replace(/#/, ""));
let previousParams: any = {};
for (let [key, value] of paramsFromHash.entries()) {
previousParams[key] = value;
Expand Down
12 changes: 6 additions & 6 deletions src/helpers/decodeQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function decodeQuery(
values: [],
};
const valueObj: any = {
name: regexQuery[1]?.replaceAll('"', ""),
name: regexQuery[1]?.replaceAll(/"/, ""),
selected: true,
inverted: true,
};
Expand All @@ -45,7 +45,7 @@ export function decodeQuery(

values.forEach((value) => {
const valueObj = {
name: value?.replaceAll('"', ""),
name: value?.replaceAll(/"/, ""),
selected: true,
inverted: false,
};
Expand All @@ -60,7 +60,7 @@ export function decodeQuery(
values: [],
};
const valueObj = {
name: regexQuery[1]?.replaceAll('"', ""),
name: regexQuery[1]?.replaceAll(/"/, ""),
selected: true,
inverted: false,
};
Expand Down Expand Up @@ -146,7 +146,7 @@ export function decodeExpr(expr: string) {
};

const valueObj: any = {
name: regexQuery[1]?.replaceAll('"', ""),
name: regexQuery[1]?.replaceAll(/"/, ""),
selected: true,
inverted: true,
};
Expand All @@ -163,7 +163,7 @@ export function decodeExpr(expr: string) {

values.forEach((value) => {
const valueObj: any = {
name: value?.replaceAll('"', ""),
name: value?.replaceAll(/"/, ""),
selected: true,
inverted: false,
};
Expand All @@ -180,7 +180,7 @@ export function decodeExpr(expr: string) {
};

const valueObj: any = {
name: regexQuery[1]?.replaceAll('"', ""),
name: regexQuery[1]?.replaceAll(/"/, ""),
selected: true,
inverted: false,
};
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/stateFromQueryParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function stateFromQueryParams() {
const { hash } = window.location;
if (debug) console.log("🚧 LOGIC/FromQuery Hash", hash);

const urlFromHash = new URLSearchParams(hash.replace("#", ""));
const urlFromHash = new URLSearchParams(hash.replace(/#/, ""));

if (debug) console.log("🚧 LOGIC/urlFromHash", urlFromHash, hash.length);

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/useQueryParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function useQueryParams() {

const paramsFromUrl = useMemo(() => {
if (hash) {
const searchParams = new URLSearchParams(hash.replace("#", ""));
const searchParams = new URLSearchParams(hash.replace(/#/, ""));
let memoParams: any = {};

for (let [key, value] of searchParams.entries()) {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/queryhistory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ const QueryHistory = (props: any) => {
intval * (window as any).devicePixelRatio.toFixed(2)
);
querySubmit = queryInput.replace(
"[$__interval]",
/\[\$__interval\]/,
`[${ratiointval}s]`
);
customStep = ratiointval;
Expand Down Expand Up @@ -1019,7 +1019,7 @@ const QueryHistory = (props: any) => {
function copyQuery(item: any, type = "query", isRelative = false) {
const url = new URL(item);
const { hash } = url;
const params = new URLSearchParams(hash.replace("#", ""));
const params = new URLSearchParams(hash.replace(/#/, ""));
params.set("label", label);
const locationWithLabel = new URL(window.location.href);
locationWithLabel.hash = `#${params.toString()}`;
Expand Down
2 changes: 1 addition & 1 deletion src/services/localUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const localUrl = () => {

const { hash } = window.location;
const origin = window.location.origin;
const urlParams = new URLSearchParams(hash.replace("#", ""));
const urlParams = new URLSearchParams(hash.replace(/#/, ""));
let paramsData: any = {};
urlParams.set("isSubmit", "true");
for (let [key, value] of urlParams) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/DataSources/DataSources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useMediaQuery } from "react-responsive";

export function getURlParams(params: any) {

const url = params.replace('#','')
const url = params.replace(/#/,'')
const decoded = decodeURIComponent(url)
const urlParams = new URLSearchParams(decoded)
let panels = {left:'', right:''}
Expand Down
2 changes: 1 addition & 1 deletion src/views/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function Main() {
const { hash } = useLocation();
// get url params as object
const paramsMemo = useMemo(() => {
return new URLSearchParams(hash.replace("#", ""));
return new URLSearchParams(hash.replace(/#/, ""));
}, [hash]);
//
UpdateStateFromQueryParams();
Expand Down

0 comments on commit 7b2b435

Please sign in to comment.