1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.isValidTagValue = exports.isValidTagKey = void 0;
|
19 | const nonPrintableCharsRegex = /[^\u0020-\u007e]/;
|
20 | const TAG_KEY_MAX_LENGTH = 255;
|
21 |
|
22 | function isValidTagKey(tagKey) {
|
23 | if (!tagKey || !tagKey.name) {
|
24 | return false;
|
25 | }
|
26 | return (isPrintableString(tagKey.name) &&
|
27 | tagKey.name.length > 0 &&
|
28 | tagKey.name.length <= TAG_KEY_MAX_LENGTH);
|
29 | }
|
30 | exports.isValidTagKey = isValidTagKey;
|
31 |
|
32 | function isValidTagValue(tagValue) {
|
33 | if (!tagValue || tagValue.value === null || tagValue.value === undefined) {
|
34 | return false;
|
35 | }
|
36 | return (isPrintableString(tagValue.value) &&
|
37 | tagValue.value.length <= TAG_KEY_MAX_LENGTH);
|
38 | }
|
39 | exports.isValidTagValue = isValidTagValue;
|
40 | function isPrintableString(name) {
|
41 | return !nonPrintableCharsRegex.test(name);
|
42 | }
|
43 |
|
\ | No newline at end of file |