mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-15 18:25:54 +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 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
|
||||
const RESTRICTED_FIELDS = ['timestamp'];
|
||||
@ -58,7 +63,7 @@ function TableView({
|
||||
.map((key) => ({
|
||||
key,
|
||||
field: key,
|
||||
value: JSON.stringify(flattenLogData[key]),
|
||||
value: removeEscapeCharacters(JSON.stringify(flattenLogData[key])),
|
||||
}));
|
||||
|
||||
const onTraceHandler = (record: DataType) => (): void => {
|
||||
|
@ -226,3 +226,17 @@ export const getDataTypes = (value: unknown): DataTypes => {
|
||||
|
||||
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