@joliegg/moderation 0.3.6 → 0.3.7
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/dist/index.js +12 -3
- package/package.json +1 -1
- package/src/index.ts +13 -4
package/dist/index.js
CHANGED
|
@@ -129,9 +129,18 @@ class ModerationClient {
|
|
|
129
129
|
async moderateLink(url, allowShorteners = false) {
|
|
130
130
|
const blacklisted = this.urlBlackList?.some(b => url.indexOf(b) > -1);
|
|
131
131
|
if (!allowShorteners) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
try {
|
|
133
|
+
const domain = new URL(url).hostname;
|
|
134
|
+
const isShortened = url_shorteners_json_1.default.some(s => s.indexOf(domain) > -1);
|
|
135
|
+
if (isShortened) {
|
|
136
|
+
return { source: url, moderation: [{ category: 'URL_SHORTENER', confidence: 100 }] };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
const isShortened = url_shorteners_json_1.default.some(s => url.indexOf(s) > -1);
|
|
141
|
+
if (isShortened) {
|
|
142
|
+
return { source: url, moderation: [{ category: 'URL_SHORTENER', confidence: 100 }] };
|
|
143
|
+
}
|
|
135
144
|
}
|
|
136
145
|
}
|
|
137
146
|
if (blacklisted) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -159,10 +159,19 @@ class ModerationClient {
|
|
|
159
159
|
const blacklisted = this.urlBlackList?.some(b => url.indexOf(b) > -1);
|
|
160
160
|
|
|
161
161
|
if (!allowShorteners) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
try {
|
|
163
|
+
const domain = new URL(url).hostname;
|
|
164
|
+
const isShortened = URLShortenerList.some(s => s.indexOf(domain) > -1);
|
|
165
|
+
|
|
166
|
+
if (isShortened) {
|
|
167
|
+
return { source: url, moderation: [{ category: 'URL_SHORTENER', confidence: 100 }] };
|
|
168
|
+
}
|
|
169
|
+
} catch (e) {
|
|
170
|
+
const isShortened = URLShortenerList.some(s => url.indexOf(s) > -1);
|
|
171
|
+
|
|
172
|
+
if (isShortened) {
|
|
173
|
+
return { source: url, moderation: [{ category: 'URL_SHORTENER', confidence: 100 }] };
|
|
174
|
+
}
|
|
166
175
|
}
|
|
167
176
|
}
|
|
168
177
|
|