@jayfong/x-server 1.34.0 → 1.34.1
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.
|
@@ -38,13 +38,20 @@ class SensitiveWordsService {
|
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
async validate(text) {
|
|
41
|
+
async validate(text, every) {
|
|
42
42
|
if (!this.mint) {
|
|
43
43
|
this.mint = new _mintFilter.default(this.options.words);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const res = this.mint.
|
|
47
|
-
|
|
46
|
+
const res = await this.mint.filter(text, {
|
|
47
|
+
replace: false,
|
|
48
|
+
every: !!every,
|
|
49
|
+
words: true
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
pass: !!res.pass,
|
|
53
|
+
words: res.words
|
|
54
|
+
};
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
}
|
|
@@ -18,7 +18,10 @@ export declare class SensitiveWordsService implements BaseService {
|
|
|
18
18
|
/**
|
|
19
19
|
* 验证文本是否包含敏感词。
|
|
20
20
|
*/
|
|
21
|
-
validate(text: string): Promise<
|
|
21
|
+
validate(text: string, every?: boolean): Promise<{
|
|
22
|
+
pass: boolean;
|
|
23
|
+
words: string[];
|
|
24
|
+
}>;
|
|
22
25
|
}
|
|
23
26
|
declare module '../x' {
|
|
24
27
|
interface X {
|
|
@@ -31,13 +31,20 @@ export class SensitiveWordsService {
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
async validate(text) {
|
|
34
|
+
async validate(text, every) {
|
|
35
35
|
if (!this.mint) {
|
|
36
36
|
this.mint = new Mint(this.options.words);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
const res = this.mint.
|
|
40
|
-
|
|
39
|
+
const res = await this.mint.filter(text, {
|
|
40
|
+
replace: false,
|
|
41
|
+
every: !!every,
|
|
42
|
+
words: true
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
pass: !!res.pass,
|
|
46
|
+
words: res.words
|
|
47
|
+
};
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
}
|