Skip to content

Commit 74d0c01

Browse files
committed
move HTML_TAG_PATTERN to consts
1 parent 2553a87 commit 74d0c01

4 files changed

Lines changed: 7 additions & 9 deletions

File tree

src/CONST/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,6 +2496,9 @@ const CONST = {
24962496

24972497
VALIDATE_FOR_LEADING_SPACES_HTML_TAG_REGEX: /<([\s]+.+[\s]*)>/g,
24982498

2499+
// Matches an opening or closing HTML tag that starts with a letter (e.g. <b>, </strong>, <br/>)
2500+
HTML_TAG_REGEX: /<\/?[a-z][^>]*>/i,
2501+
24992502
WHITELISTED_TAGS: [/<>/, /< >/, /<->/, /<-->/, /<br>/, /<br\/>/],
25002503

25012504
PUSHER: {

src/components/DotIndicatorMessage.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import Icon from './Icon';
2525
import RenderHTML from './RenderHTML';
2626
import Text from './Text';
2727

28-
const HTML_TAG_PATTERN = /<\/?[a-z][^>]*>/i;
29-
3028
type DotIndicatorMessageProps = {
3129
/**
3230
* In most cases this should just be errors from onxyData
@@ -96,7 +94,7 @@ function DotIndicatorMessage({messages = {}, style, type, textStyles, dismissErr
9694
);
9795
}
9896

99-
if (HTML_TAG_PATTERN.test(displayMessage)) {
97+
if (CONST.HTML_TAG_REGEX.test(displayMessage)) {
10098
const html = isErrorMessage ? `<rbr>${displayMessage}</rbr>` : `<muted-text-label>${displayMessage}</muted-text-label>`;
10199

102100
return (

src/components/TransactionItemRow/TransactionItemRowRBR.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import ViolationsUtils from '@libs/Violations/ViolationsUtils';
1818

1919
import variables from '@styles/variables';
2020

21+
import CONST from '@src/CONST';
2122
import ONYXKEYS from '@src/ONYXKEYS';
2223
import ROUTES from '@src/ROUTES';
2324
import type {Report, TransactionViolation} from '@src/types/onyx';
@@ -29,8 +30,6 @@ import type {ViewStyle} from 'react-native';
2930
import React from 'react';
3031
import {View} from 'react-native';
3132

32-
const HTML_TAG_PATTERN = /<\/?[a-z][^>]*>/i;
33-
3433
type TransactionItemRowRBRInnerProps = {
3534
/** Transaction item */
3635
transaction: Transaction;
@@ -89,7 +88,7 @@ function TransactionItemRowRBRInner({transaction, violations, report, containerS
8988
isMarkAsCash: isMarkAsCash || undefined,
9089
canEdit,
9190
});
92-
const hasHTMLTags = HTML_TAG_PATTERN.test(RBRMessages);
91+
const hasHTMLTags = CONST.HTML_TAG_REGEX.test(RBRMessages);
9392

9493
return (
9594
RBRMessages.length > 0 && (

src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ import {useIsFocused} from '@react-navigation/native';
3434
import React, {useCallback, useEffect, useRef} from 'react';
3535
import {View} from 'react-native';
3636

37-
const HTML_TAG_PATTERN = /<\/?[a-z][^>]*>/i;
38-
3937
type DeleteWorkspaceFlowProps = {
4038
/** ID of the workspace being deleted */
4139
policyID: string;
@@ -131,7 +129,7 @@ function DeleteWorkspaceFlow({policyID, onDismiss, onDeleteComplete}: DeleteWork
131129
return;
132130
}
133131

134-
const prompt = HTML_TAG_PATTERN.test(errorMessage) ? (
132+
const prompt = CONST.HTML_TAG_REGEX.test(errorMessage) ? (
135133
<View style={[styles.renderHTML, styles.flexRow]}>
136134
<RenderHTML
137135
html={errorMessage}

0 commit comments

Comments
 (0)