Restore the v2.1.19 application baseline and retain only the focused import preflight summary with duplicate, unavailable, destination, job, and size-limit visibility.
This commit is contained in:
+26
-24
@@ -11,13 +11,13 @@ const HOSTER_RESULT_DOMAINS = {
|
||||
'doodstream.com': ['doodstream.com', 'dood.to', 'dood.la', 'dood.so', 'dsvplay.com']
|
||||
};
|
||||
|
||||
function isExpectedHostUrl(value, expectedHost, allowHttp = false) {
|
||||
function isExpectedHostUrl(value, expectedHost) {
|
||||
if (typeof value !== 'string' || value.trim() === '') return false;
|
||||
try {
|
||||
const url = new URL(value);
|
||||
const hostname = url.hostname.toLowerCase();
|
||||
const acceptedDomains = HOSTER_RESULT_DOMAINS[expectedHost] || [expectedHost];
|
||||
return (url.protocol === 'https:' || (allowHttp && url.protocol === 'http:'))
|
||||
return (url.protocol === 'http:' || url.protocol === 'https:')
|
||||
&& acceptedDomains.some(domain => hostname === domain || hostname.endsWith(`.${domain}`));
|
||||
} catch {
|
||||
return false;
|
||||
@@ -32,15 +32,25 @@ function getUrlHost(value) {
|
||||
}
|
||||
}
|
||||
|
||||
function selectPublicUploadUrl(result) {
|
||||
for (const value of [result?.download_url, result?.embed_url]) {
|
||||
if (typeof value !== 'string' || value.trim() === '') continue;
|
||||
try {
|
||||
const url = new URL(value.trim());
|
||||
if (url.protocol === 'https:') return url.href;
|
||||
} catch {}
|
||||
}
|
||||
return '';
|
||||
function normalizeDoodstreamUrl(value) {
|
||||
if (typeof value !== 'string' || value.trim() === '') return value;
|
||||
try {
|
||||
const url = new URL(value);
|
||||
const hostname = url.hostname.toLowerCase();
|
||||
if (hostname !== 'doodstream.com' && HOSTER_RESULT_DOMAINS['doodstream.com'].includes(hostname)) {
|
||||
url.hostname = 'doodstream.com';
|
||||
return url.toString();
|
||||
}
|
||||
} catch {}
|
||||
return value;
|
||||
}
|
||||
|
||||
function normalizeConfirmedResult(result, hoster) {
|
||||
if (hoster !== 'doodstream.com') return result;
|
||||
const downloadUrl = normalizeDoodstreamUrl(result.download_url);
|
||||
const embedUrl = normalizeDoodstreamUrl(result.embed_url);
|
||||
if (downloadUrl === result.download_url && embedUrl === result.embed_url) return result;
|
||||
return { ...result, download_url: downloadUrl, embed_url: embedUrl };
|
||||
}
|
||||
|
||||
function assertUploadConfirmation(result, hoster) {
|
||||
@@ -51,18 +61,10 @@ function assertUploadConfirmation(result, hoster) {
|
||||
&& value !== undefined
|
||||
&& !(typeof value === 'string' && value.trim() === '')
|
||||
));
|
||||
if (SUPPORTED_HOSTERS.has(expectedHost) && FILE_CODE_PATTERN.test(fileCode)) {
|
||||
if (expectedHost === 'doodstream.com' && urls.every(value => isExpectedHostUrl(value, expectedHost, true))) {
|
||||
return {
|
||||
...result,
|
||||
file_code: fileCode,
|
||||
download_url: `https://doodstream.com/d/${fileCode}`,
|
||||
embed_url: `https://doodstream.com/e/${fileCode}`
|
||||
};
|
||||
}
|
||||
if (urls.length > 0 && urls.every(value => isExpectedHostUrl(value, expectedHost))) {
|
||||
return fileCode === result.file_code ? result : { ...result, file_code: fileCode };
|
||||
}
|
||||
if (SUPPORTED_HOSTERS.has(expectedHost)
|
||||
&& FILE_CODE_PATTERN.test(fileCode)
|
||||
&& urls.every(value => isExpectedHostUrl(value, expectedHost))) {
|
||||
return normalizeConfirmedResult(result, expectedHost);
|
||||
}
|
||||
const error = new Error(`Upload zu ${hoster || 'unbekanntem Hoster'} wurde nicht bestätigt`);
|
||||
error.diagnostic = {
|
||||
@@ -74,4 +76,4 @@ function assertUploadConfirmation(result, hoster) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
module.exports = { assertUploadConfirmation, selectPublicUploadUrl };
|
||||
module.exports = { assertUploadConfirmation };
|
||||
|
||||
Reference in New Issue
Block a user