content: exclude links to ip addresses #53
|
@ -31,6 +31,9 @@ function isValidURL(url) {
|
||||||
if (!['', '443', '80'].includes(url.port)) {
|
if (!['', '443', '80'].includes(url.port)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (url.hostname === 'localhost') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const lastDot = url.hostname.lastIndexOf('.');
|
const lastDot = url.hostname.lastIndexOf('.');
|
||||||
if (lastDot < 1) {
|
if (lastDot < 1) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -38,6 +41,12 @@ function isValidURL(url) {
|
||||||
if (url.hostname.slice(lastDot) === '.local') {
|
if (url.hostname.slice(lastDot) === '.local') {
|
||||||
offbyn marked this conversation as resolved
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (url.hostname.slice(lastDot + 1).match(/^[\d]+$/)) { // there should be no tld with numbers, possible ipv4
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (url.hostname.includes(':')) { // possibly an ipv6 addr; certainly an invalid hostname
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
btw, also refuse localhost?