Scanner and rotator accept bare domains (scheme added for them); clearer scanner error
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,8 @@ function init(opts) { DATA_DIR = opts.dataDir; ownHosts = opts.ownHosts || (() =
|
||||
const norm = e => String(e || '').trim().toLowerCase();
|
||||
const TYPES = ['bridge', 'review', 'squeeze'];
|
||||
const cleanUrl = u => { const s = String(u || '').trim(); return /^https?:\/\/[^\s"'<>]+$/i.test(s) && s.length <= 700 ? s : ''; };
|
||||
// people type bare domains ("cryptoteambuild.com"): give them the scheme before judging the address (Marty 2026-10-07)
|
||||
const withScheme = u => { const s = String(u || '').trim(); return s && !/^[a-z][a-z0-9+.-]*:\/\//i.test(s) && /^[^\s\/]+\.[^\s]+/.test(s) ? 'https://' + s : s; };
|
||||
const slugify = t => (String(t || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40) || 'page') + '-' + crypto.randomBytes(3).toString('hex');
|
||||
const strs = (arr, n, len) => (Array.isArray(arr) ? arr : String(arr || '').split('\n')).map(x => String(x).trim()).filter(Boolean).slice(0, n).map(x => x.slice(0, len));
|
||||
|
||||
@@ -98,7 +100,7 @@ function fetchText(url, hops) {
|
||||
const meta = (h, name) => { const m = h.match(new RegExp('<meta[^>]+(?:property|name)=["\']' + name + '["\'][^>]*content=["\']([^"\']*)', 'i')) || h.match(new RegExp('<meta[^>]+content=["\']([^"\']*)["\'][^>]*(?:property|name)=["\']' + name + '["\']', 'i')); return m ? m[1].trim() : ''; };
|
||||
const strip = s => String(s || '').replace(/<[^>]+>/g, ' ').replace(/ /g, ' ').replace(/&/g, '&').replace(/'|'/g, "'").replace(/"/g, '"').replace(/\s+/g, ' ').trim();
|
||||
async function scan(url) {
|
||||
url = cleanUrl(url); if (!url) return { error: 'Give the scanner a full https:// address.' };
|
||||
url = cleanUrl(withScheme(url)); if (!url) return { error: 'Give the scanner a website address, like example.com or https://example.com/page.' };
|
||||
const host = new URL(url).hostname.toLowerCase();
|
||||
if (!host.includes('.') || net.isIP(host)) return { error: 'Scan a public website address.' };
|
||||
try { const rs = await dns.lookup(host, { all: true }); if (!rs.length || rs.some(r => isPrivateIp(r.address))) return { error: 'That host is not reachable from here.' }; } catch (e) { return { error: 'That host does not resolve.' }; }
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ function init(opts) { DATA_DIR = opts.dataDir; geo = opts.geo || null; OWN_HOSTS
|
||||
const norm = e => String(e || '').trim().toLowerCase();
|
||||
const newCode = () => { const a = 'abcdefghjkmnpqrstuvwxyz23456789'; let s = ''; for (let i = 0; i < 6; i++) s += a[crypto.randomInt(a.length)]; return s; };
|
||||
const BOT = /bot|crawl|spider|slurp|facebookexternalhit|preview|telegrambot|whatsapp|curl|wget|python-requests|headless/i;
|
||||
const cleanUrl = u => { const s = String(u || '').trim(); return /^https?:\/\/[^\s]+$/i.test(s) && s.length <= 500 ? s : null; };
|
||||
const cleanUrl = u => { let s = String(u || '').trim(); if (s && !/^[a-z][a-z0-9+.-]*:\/\//i.test(s) && /^[^\s\/]+\.[^\s]+/.test(s)) s = 'https://' + s; return /^https?:\/\/[^\s]+$/i.test(s) && s.length <= 500 ? s : null; };
|
||||
|
||||
function pub(r) {
|
||||
const hits = J.db.hits.filter(h => h.r === r.id);
|
||||
|
||||
Reference in New Issue
Block a user