Require public URLs for upload output

This commit is contained in:
Sucukdeluxe
2026-08-13 20:52:12 +02:00
parent 31b5766254
commit 967fef4eed
4 changed files with 25 additions and 5 deletions
+12 -1
View File
@@ -32,6 +32,17 @@ 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 assertUploadConfirmation(result, hoster) {
const expectedHost = typeof hoster === 'string' ? hoster.trim().toLowerCase() : '';
const fileCode = typeof result?.file_code === 'string' ? result.file_code.trim() : '';
@@ -63,4 +74,4 @@ function assertUploadConfirmation(result, hoster) {
throw error;
}
module.exports = { assertUploadConfirmation };
module.exports = { assertUploadConfirmation, selectPublicUploadUrl };