@jayfong/x-server 1.33.4 → 1.33.5
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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.33.5](https://github.com/jfWorks/x-server/compare/v1.33.4...v1.33.5) (2022-08-21)
|
|
6
|
+
|
|
5
7
|
### [1.33.4](https://github.com/jfWorks/x-server/compare/v1.33.3...v1.33.4) (2022-07-17)
|
|
6
8
|
|
|
7
9
|
|
|
@@ -33,6 +33,19 @@ class SensitiveWordsService {
|
|
|
33
33
|
});
|
|
34
34
|
return res.text;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* 验证文本是否包含敏感词。
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
async validate(text) {
|
|
42
|
+
if (!this.mint) {
|
|
43
|
+
this.mint = new _mintFilter.default(this.options.words);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const res = this.mint.validator(text);
|
|
47
|
+
return res;
|
|
48
|
+
}
|
|
36
49
|
|
|
37
50
|
}
|
|
38
51
|
|
|
@@ -15,6 +15,10 @@ export declare class SensitiveWordsService implements BaseService {
|
|
|
15
15
|
* 处理文本,敏感词将被替换为 * 号。
|
|
16
16
|
*/
|
|
17
17
|
process(text: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* 验证文本是否包含敏感词。
|
|
20
|
+
*/
|
|
21
|
+
validate(text: string): Promise<boolean>;
|
|
18
22
|
}
|
|
19
23
|
declare module '../x' {
|
|
20
24
|
interface X {
|
|
@@ -26,5 +26,18 @@ export class SensitiveWordsService {
|
|
|
26
26
|
});
|
|
27
27
|
return res.text;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* 验证文本是否包含敏感词。
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
async validate(text) {
|
|
35
|
+
if (!this.mint) {
|
|
36
|
+
this.mint = new Mint(this.options.words);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const res = this.mint.validator(text);
|
|
40
|
+
return res;
|
|
41
|
+
}
|
|
29
42
|
|
|
30
43
|
}
|