Lazyload blacklist URLs
This commit is contained in:
parent
4acae4608a
commit
bb835d2732
1 changed files with 7 additions and 4 deletions
11
src/util.js
11
src/util.js
|
|
@ -5,10 +5,7 @@ import { fileURLToPath } from "url";
|
||||||
|
|
||||||
const recordParamDestUrl = 'forward-domain';
|
const recordParamDestUrl = 'forward-domain';
|
||||||
const recordParamHttpStatus = 'http-status';
|
const recordParamHttpStatus = 'http-status';
|
||||||
const blacklistURL = (process.env.BLACKLIST_HOSTS || "").split(',').reduce((acc, host) => {
|
let blacklistURL = null;
|
||||||
acc[host] = true;
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {crypto.BinaryLike} str
|
* @param {crypto.BinaryLike} str
|
||||||
|
|
@ -18,6 +15,12 @@ export function md5(str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isHostBlacklisted(domain = '') {
|
export function isHostBlacklisted(domain = '') {
|
||||||
|
if (!blacklistURL) {
|
||||||
|
blacklistURL = (process.env.BLACKLIST_HOSTS || "").split(',').reduce((acc, host) => {
|
||||||
|
acc[host] = true;
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
|
}
|
||||||
if (domain.length > 6) {
|
if (domain.length > 6) {
|
||||||
let p = domain.lastIndexOf('.', domain.length - 6);
|
let p = domain.lastIndexOf('.', domain.length - 6);
|
||||||
if (p > 0) {
|
if (p > 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue