revdev 0.30.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/utils/regex.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export declare class RegexUtil {
|
|
2
2
|
private static slugRegex;
|
|
3
|
+
private static usernameRegex;
|
|
3
4
|
private static tagCodeRegex;
|
|
4
5
|
private static emailRegex;
|
|
5
6
|
static slug(slug: string): boolean;
|
|
7
|
+
static username(slug: string): boolean;
|
|
6
8
|
static tagCode(code: string): boolean;
|
|
7
9
|
static email(code: string): boolean;
|
|
8
10
|
}
|
package/lib/utils/regex.js
CHANGED
|
@@ -8,6 +8,10 @@ var RegexUtil = /** @class */ (function () {
|
|
|
8
8
|
this.slugRegex.lastIndex = 0;
|
|
9
9
|
return this.slugRegex.test(slug);
|
|
10
10
|
};
|
|
11
|
+
RegexUtil.username = function (slug) {
|
|
12
|
+
this.usernameRegex.lastIndex = 0;
|
|
13
|
+
return this.usernameRegex.test(slug);
|
|
14
|
+
};
|
|
11
15
|
RegexUtil.tagCode = function (code) {
|
|
12
16
|
this.tagCodeRegex.lastIndex = 0;
|
|
13
17
|
return this.tagCodeRegex.test(code);
|
|
@@ -18,6 +22,8 @@ var RegexUtil = /** @class */ (function () {
|
|
|
18
22
|
};
|
|
19
23
|
// min: 6, max: 50
|
|
20
24
|
RegexUtil.slugRegex = /^[a-z][a-z0-9\-]{4,48}[a-z0-9]$/g;
|
|
25
|
+
// min: 6, max: 50
|
|
26
|
+
RegexUtil.usernameRegex = /^[a-z][a-z0-9]{5,48}$/g;
|
|
21
27
|
RegexUtil.tagCodeRegex = /^[a-z]([\-]?[a-z]+)*$/g;
|
|
22
28
|
RegexUtil.emailRegex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
23
29
|
return RegexUtil;
|
|
@@ -19,6 +19,22 @@ describe("RegexUtil", function () {
|
|
|
19
19
|
validate("1mylist", false);
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
|
+
describe("username", function () {
|
|
23
|
+
function validate(text, valid) {
|
|
24
|
+
if (valid === void 0) { valid = true; }
|
|
25
|
+
expect(regex_1.RegexUtil.username(text)).toBe(valid);
|
|
26
|
+
}
|
|
27
|
+
test("true", function () {
|
|
28
|
+
validate("mylist");
|
|
29
|
+
validate("mylist25");
|
|
30
|
+
validate("m12345");
|
|
31
|
+
});
|
|
32
|
+
test("false", function () {
|
|
33
|
+
validate("my", false);
|
|
34
|
+
validate("-mylist", false);
|
|
35
|
+
validate("1mylist", false);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
22
38
|
describe("tag", function () {
|
|
23
39
|
function validate(text, valid) {
|
|
24
40
|
if (valid === void 0) { valid = true; }
|