1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.validateTopics = exports.validateTopic = void 0;
|
4 | function validateTopic(topic) {
|
5 | const parts = topic.split('/');
|
6 | for (let i = 0; i < parts.length; i++) {
|
7 | if (parts[i] === '+') {
|
8 | continue;
|
9 | }
|
10 | if (parts[i] === '#') {
|
11 | return i === parts.length - 1;
|
12 | }
|
13 | if (parts[i].indexOf('+') !== -1 || parts[i].indexOf('#') !== -1) {
|
14 | return false;
|
15 | }
|
16 | }
|
17 | return true;
|
18 | }
|
19 | exports.validateTopic = validateTopic;
|
20 | function validateTopics(topics) {
|
21 | if (topics.length === 0) {
|
22 | return 'empty_topic_list';
|
23 | }
|
24 | for (let i = 0; i < topics.length; i++) {
|
25 | if (!validateTopic(topics[i])) {
|
26 | return topics[i];
|
27 | }
|
28 | }
|
29 | return null;
|
30 | }
|
31 | exports.validateTopics = validateTopics;
|
32 |
|
\ | No newline at end of file |