mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-17 05:35:55 +08:00
refactor: removed escape character from the string (#3726)
This commit is contained in:
parent
2494b64ccd
commit
7fa50070ce
@ -21,7 +21,12 @@ import { ILog } from 'types/api/logs/log';
|
|||||||
|
|
||||||
import ActionItem, { ActionItemProps } from './ActionItem';
|
import ActionItem, { ActionItemProps } from './ActionItem';
|
||||||
import FieldRenderer from './FieldRenderer';
|
import FieldRenderer from './FieldRenderer';
|
||||||
import { flattenObject, jsonToDataNodes, recursiveParseJSON } from './utils';
|
import {
|
||||||
|
flattenObject,
|
||||||
|
jsonToDataNodes,
|
||||||
|
recursiveParseJSON,
|
||||||
|
removeEscapeCharacters,
|
||||||
|
} from './utils';
|
||||||
|
|
||||||
// Fields which should be restricted from adding it to query
|
// Fields which should be restricted from adding it to query
|
||||||
const RESTRICTED_FIELDS = ['timestamp'];
|
const RESTRICTED_FIELDS = ['timestamp'];
|
||||||
@ -58,7 +63,7 @@ function TableView({
|
|||||||
.map((key) => ({
|
.map((key) => ({
|
||||||
key,
|
key,
|
||||||
field: key,
|
field: key,
|
||||||
value: JSON.stringify(flattenLogData[key]),
|
value: removeEscapeCharacters(JSON.stringify(flattenLogData[key])),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const onTraceHandler = (record: DataType) => (): void => {
|
const onTraceHandler = (record: DataType) => (): void => {
|
||||||
|
@ -226,3 +226,17 @@ export const getDataTypes = (value: unknown): DataTypes => {
|
|||||||
|
|
||||||
return determineType(value);
|
return determineType(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const removeEscapeCharacters = (str: string): string =>
|
||||||
|
str.replace(/\\([ntfr'"\\])/g, (_: string, char: string) => {
|
||||||
|
const escapeMap: Record<string, string> = {
|
||||||
|
n: '\n',
|
||||||
|
t: '\t',
|
||||||
|
f: '\f',
|
||||||
|
r: '\r',
|
||||||
|
"'": "'",
|
||||||
|
'"': '"',
|
||||||
|
'\\': '\\',
|
||||||
|
};
|
||||||
|
return escapeMap[char as keyof typeof escapeMap];
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user