diff --git a/lib/hosters.js b/lib/hosters.js index 1069243..b28c981 100644 --- a/lib/hosters.js +++ b/lib/hosters.js @@ -8,6 +8,7 @@ const API_TIMEOUT = 45000; // 45 seconds const SERVER_RETRY_ATTEMPTS = 6; const SERVER_RETRY_DELAY_MS = 2500; const LAST_UPLOAD_SERVERS = new Map(); +const TRUNCATED_UPLOAD_HOST = /(^|\.)filemoon$/i; function appendRawQuery(url, rawQuery) { const parsed = new URL(url); @@ -79,6 +80,7 @@ function normalizeAbsoluteUrl(raw, apiBase) { try { const parsed = new URL(candidate); if (!['http:', 'https:'].includes(parsed.protocol)) return null; + if (TRUNCATED_UPLOAD_HOST.test(parsed.hostname)) return null; return parsed.href; } catch { return null; diff --git a/tests/hosters.test.js b/tests/hosters.test.js index 9f41eef..56b8ba5 100644 --- a/tests/hosters.test.js +++ b/tests/hosters.test.js @@ -32,6 +32,19 @@ describe('hosters helpers', () => { assert.equal(url, 'https://delivery-hydra.voe-network.net/upload/01'); }); + it('rejects byse truncated upload hosts (TLD dropped) so the lookup retries for a valid server', () => { + assert.equal(__test.extractUploadServerUrl({ result: 'https://s1065.filemoon/upload/01' }, 'https://api.byse.sx'), null); + assert.equal(__test.extractUploadServerUrl({ result: 's1070.filemoon' }, 'https://api.byse.sx'), null); + assert.equal(__test.extractUploadServerUrl({ result: 'https://filemoon/upload/01' }, 'https://api.byse.sx'), null); + }); + + it('keeps a complete byse upload host (real TLD present) untouched', () => { + assert.equal( + __test.extractUploadServerUrl({ result: 'https://s1065.filemoon.sx/upload/01' }, 'https://api.byse.sx'), + 'https://s1065.filemoon.sx/upload/01' + ); + }); + it('parseDoodstreamResult tolerates null/non-object payload without throwing', () => { // Direct callers may bypass uploadFile's normalisation. The parser must // never throw on bad input — empty fields are the contract.