revdev 0.25.0 → 0.26.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/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/regex.d.ts +6 -0
- package/lib/utils/regex.js +20 -0
- package/lib/utils/tests/slug.test.js +39 -17
- package/package.json +1 -1
- package/lib/utils/slug.d.ts +0 -4
- package/lib/utils/slug.js +0 -15
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -13,4 +13,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
__exportStar(require("./feed"), exports);
|
|
14
14
|
__exportStar(require("./converter"), exports);
|
|
15
15
|
__exportStar(require("./string"), exports);
|
|
16
|
-
__exportStar(require("./
|
|
16
|
+
__exportStar(require("./regex"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegexUtil = void 0;
|
|
4
|
+
var RegexUtil = /** @class */ (function () {
|
|
5
|
+
function RegexUtil() {
|
|
6
|
+
}
|
|
7
|
+
RegexUtil.isSlug = function (slug) {
|
|
8
|
+
this.slugRegex.lastIndex = 0;
|
|
9
|
+
return this.slugRegex.test(slug);
|
|
10
|
+
};
|
|
11
|
+
RegexUtil.isTagCode = function (code) {
|
|
12
|
+
this.tagCodeRegex.lastIndex = 0;
|
|
13
|
+
return this.tagCodeRegex.test(code);
|
|
14
|
+
};
|
|
15
|
+
// min: 6, max: 50
|
|
16
|
+
RegexUtil.slugRegex = /^[a-z][a-z0-9\-]{4,48}[a-z0-9]$/g;
|
|
17
|
+
RegexUtil.tagCodeRegex = /^[a-z]([\-]?[a-z]+)*$/g;
|
|
18
|
+
return RegexUtil;
|
|
19
|
+
}());
|
|
20
|
+
exports.RegexUtil = RegexUtil;
|
|
@@ -1,22 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
var regex_1 = require("../regex");
|
|
4
|
+
describe("RegexUtil", function () {
|
|
5
|
+
describe("slug", function () {
|
|
6
|
+
function trueSlug(text) {
|
|
7
|
+
expect(regex_1.RegexUtil.isSlug(text)).toBe(true);
|
|
8
|
+
}
|
|
9
|
+
function falseSlug(text) {
|
|
10
|
+
expect(regex_1.RegexUtil.isSlug(text)).toBe(false);
|
|
11
|
+
}
|
|
12
|
+
test("true", function () {
|
|
13
|
+
trueSlug("my-list");
|
|
14
|
+
trueSlug("mylist");
|
|
15
|
+
trueSlug("mylist-25");
|
|
16
|
+
trueSlug("m12345");
|
|
17
|
+
});
|
|
18
|
+
test("false", function () {
|
|
19
|
+
falseSlug("my");
|
|
20
|
+
falseSlug("-mylist");
|
|
21
|
+
falseSlug("1mylist");
|
|
22
|
+
});
|
|
16
23
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
describe("tag", function () {
|
|
25
|
+
function trueCode(text) {
|
|
26
|
+
expect(regex_1.RegexUtil.isTagCode(text)).toBe(true);
|
|
27
|
+
}
|
|
28
|
+
function falseCode(text) {
|
|
29
|
+
expect(regex_1.RegexUtil.isTagCode(text)).toBe(false);
|
|
30
|
+
}
|
|
31
|
+
test("true", function () {
|
|
32
|
+
trueCode("my-code");
|
|
33
|
+
trueCode("tag");
|
|
34
|
+
trueCode("a");
|
|
35
|
+
trueCode("abcd-e-ef-ji");
|
|
36
|
+
});
|
|
37
|
+
test("false", function () {
|
|
38
|
+
falseCode("");
|
|
39
|
+
falseCode("a-");
|
|
40
|
+
falseCode("-b");
|
|
41
|
+
falseCode("my1");
|
|
42
|
+
});
|
|
21
43
|
});
|
|
22
44
|
});
|
package/package.json
CHANGED
package/lib/utils/slug.d.ts
DELETED
package/lib/utils/slug.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlugUtil = void 0;
|
|
4
|
-
var SlugUtil = /** @class */ (function () {
|
|
5
|
-
function SlugUtil() {
|
|
6
|
-
}
|
|
7
|
-
SlugUtil.isSlug = function (slug) {
|
|
8
|
-
this.slugRegex.lastIndex = 0;
|
|
9
|
-
return this.slugRegex.test(slug);
|
|
10
|
-
};
|
|
11
|
-
// min: 6, max: 50
|
|
12
|
-
SlugUtil.slugRegex = /^[a-z][a-z0-9\-]{4,48}[a-z0-9]$/g;
|
|
13
|
-
return SlugUtil;
|
|
14
|
-
}());
|
|
15
|
-
exports.SlugUtil = SlugUtil;
|