From 7debb4eea593fcb9d70d76fdf565207e864b39f7 Mon Sep 17 00:00:00 2001 From: Matias Chomicki Date: Mon, 30 Jun 2025 20:41:15 +0100 Subject: [PATCH] processing: extract regex --- public/app/features/logs/components/panel/processing.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/app/features/logs/components/panel/processing.ts b/public/app/features/logs/components/panel/processing.ts index 5a8ed40278c..b40577f1def 100644 --- a/public/app/features/logs/components/panel/processing.ts +++ b/public/app/features/logs/components/panel/processing.ts @@ -11,6 +11,7 @@ import { generateLogGrammar, generateTextMatchGrammar } from './grammar'; import { LogLineVirtualization } from './virtualization'; const TRUNCATION_DEFAULT_LENGTH = 50000; +const NEWLINES_REGEX = /(\r\n|\n|\r)/g; export class LogListModel implements LogRowModel { collapsed: boolean | undefined = undefined; @@ -101,7 +102,7 @@ export class LogListModel implements LogRowModel { ? this.raw.substring(0, this._virtualization?.getTruncationLength(null) ?? TRUNCATION_DEFAULT_LENGTH) : this.raw; if (!this._wrapLogMessage) { - this._body = this._body.replace(/(\r\n|\n|\r)/g, ''); + this._body = this._body.replace(NEWLINES_REGEX, ''); } } return this._body; @@ -146,7 +147,7 @@ export class LogListModel implements LogRowModel { fieldValue = field ? field.values.toString() : ''; } if (!this._wrapLogMessage) { - return fieldValue.replace(/(\r\n|\n|\r)/g, ''); + return fieldValue.replace(NEWLINES_REGEX, ''); } return fieldValue; }