Skip to content

Commit e65dd80

Browse files
committed
refactor: remove unsafe regex dos
1 parent cb6f751 commit e65dd80

File tree

2 files changed

+1
-20
lines changed

2 files changed

+1
-20
lines changed

src/utils/isValidTopic.util.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/utils/shouldSubscribeOrUnsubscribe.util.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { MqttClient } from 'mqtt-browser';
33
import invariant from 'tiny-warning';
44

55
import { ERROR_MESSAGES } from './constants.util';
6-
import { isValidTopic } from './isValidTopic.util';
76

87
const hasStore = (store: Store | null) => {
98
const isValid = store !== null;
@@ -21,22 +20,9 @@ const isClientConnected = (client: MqttClient | null) => {
2120
return client?.connected;
2221
};
2322

24-
const hasAllValidTopics = (topics: string | string[]) => {
25-
const isValid = Array.isArray(topics)
26-
? topics.every((topic) => isValidTopic(topic))
27-
: isValidTopic(topics);
28-
29-
if (!isValid) invariant(false, ERROR_MESSAGES.NO_VALID_TOPICS);
30-
31-
return isValid;
32-
};
33-
3423
export const shouldSubscribeOrUnsubscribe = (
35-
topics: string | string[],
3624
store: Store | null,
3725
client: MqttClient | null,
3826
) => {
39-
return (
40-
hasAllValidTopics(topics) && hasStore(store) && isClientConnected(client)
41-
);
27+
return hasStore(store) && isClientConnected(client);
4228
};

0 commit comments

Comments
 (0)