@joliegg/moderation 0.3.4 → 0.3.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/README.md +7 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -1
- package/dist/url-shorteners.json +1548 -0
- package/package.json +1 -1
- package/src/index.ts +10 -1
- package/src/url-shorteners.json +1548 -0
package/README.md
CHANGED
|
@@ -65,4 +65,11 @@ Link moderation will use the Google WebRisk API to check links. A Blacklist is a
|
|
|
65
65
|
```js
|
|
66
66
|
|
|
67
67
|
const linkModeration = await client.moderateLink('https://example.example/link');
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Link shorteners trigger a warning by default as they are considered non-trustable. If they need to be allowed, set its flag to true.
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
|
|
74
|
+
const linkModeration = await client.moderateLink('https://t.ly/link', true);
|
|
68
75
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ declare class ModerationClient {
|
|
|
35
35
|
* @returns {Promise<ModerationResult[]>} The list of results that were detected with the minimum confidence specified
|
|
36
36
|
*/
|
|
37
37
|
moderateImage(url: string, minimumConfidence?: number): Promise<ModerationResult>;
|
|
38
|
-
moderateLink(url: string): Promise<ModerationResult>;
|
|
38
|
+
moderateLink(url: string, allowShorteners?: boolean): Promise<ModerationResult>;
|
|
39
39
|
moderateAudio(url: string, language?: string, minimumConfidence?: number): Promise<ModerationResult>;
|
|
40
40
|
}
|
|
41
41
|
export default ModerationClient;
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const language_1 = require("@google-cloud/language");
|
|
|
9
9
|
const speech_1 = require("@google-cloud/speech");
|
|
10
10
|
const sharp_1 = __importDefault(require("sharp"));
|
|
11
11
|
const url_blacklist_json_1 = __importDefault(require("./url-blacklist.json"));
|
|
12
|
+
const url_shorteners_json_1 = __importDefault(require("./url-shorteners.json"));
|
|
12
13
|
/**
|
|
13
14
|
* Moderation Client
|
|
14
15
|
*
|
|
@@ -125,8 +126,14 @@ class ModerationClient {
|
|
|
125
126
|
}
|
|
126
127
|
return { source: url, moderation: [] };
|
|
127
128
|
}
|
|
128
|
-
async moderateLink(url) {
|
|
129
|
+
async moderateLink(url, allowShorteners = false) {
|
|
129
130
|
const blacklisted = this.urlBlackList?.some(b => url.indexOf(b) > -1);
|
|
131
|
+
if (!allowShorteners) {
|
|
132
|
+
const isShortened = url_shorteners_json_1.default.some(s => url.indexOf(s) > -1);
|
|
133
|
+
if (isShortened) {
|
|
134
|
+
return { source: url, moderation: [{ category: 'URL_SHORTENER', confidence: 100 }] };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
130
137
|
if (blacklisted) {
|
|
131
138
|
return { source: url, moderation: [{ category: 'CUSTOM_BLACK_LIST', confidence: 100 }] };
|
|
132
139
|
}
|