diff --git a/js/magnet.js b/js/magnet.js index 8f8eb005..8329f286 100644 --- a/js/magnet.js +++ b/js/magnet.js @@ -36,11 +36,20 @@ export function normalizeAndAugmentMagnet(rawValue, { ws = "", xs = "" } = {}) { ensureTorrentHint(params, normalizedXs, { requireHttp: false }); } - const rawWs = typeof ws === "string" ? ws.trim() : ""; - if (rawWs) { - const formattedWs = formatAbsoluteUrl(rawWs); + const wsList = Array.isArray(ws) + ? ws + : typeof ws === "string" + ? [ws] + : []; + + if (wsList.length > 0) { const allowHttpSeed = resolveAppProtocol() === "http:"; - ensureWebSeeds(params, formattedWs, { + const formattedList = wsList + .map((item) => (typeof item === "string" ? item.trim() : "")) + .filter((item) => item) + .map((item) => formatAbsoluteUrl(item)); + + ensureWebSeeds(params, formattedList, { allowHttp: allowHttpSeed, allowUnparsed: true, }); diff --git a/js/services/videoNotePayload.js b/js/services/videoNotePayload.js index 653ca2b5..32489c43 100644 --- a/js/services/videoNotePayload.js +++ b/js/services/videoNotePayload.js @@ -379,8 +379,16 @@ export function normalizeVideoNotePayload(input) { } if (legacyFormData.magnet) { + const wsList = []; + if (ws) { + wsList.push(ws); + } + if (legacyFormData.url && /^https?:\/\//i.test(legacyFormData.url)) { + wsList.push(legacyFormData.url); + } + const normalizedMagnet = normalizeAndAugmentMagnet(legacyFormData.magnet, { - ws, + ws: wsList, xs, }); legacyFormData.magnet = normalizedMagnet; diff --git a/js/ui/components/UploadModal.js b/js/ui/components/UploadModal.js index fc0cf4b8..7ecd1990 100644 --- a/js/ui/components/UploadModal.js +++ b/js/ui/components/UploadModal.js @@ -744,10 +744,16 @@ export class UploadModal { ); } + const nip71Metadata = this.nip71FormManager.collectSection("custom"); + if (nip71Metadata) { + rawPayload.nip71 = nip71Metadata; + } + const hasDirectUrl = typeof rawPayload.url === "string" && rawPayload.url.trim().length > 0; const hasMagnet = typeof rawPayload.magnet === "string" && rawPayload.magnet.trim().length > 0; + const hasImetaUrl = nip71Metadata?.imeta?.some((v) => v.url && v.url.trim().length > 0); - if (!hasDirectUrl && hasMagnet) { + if (!hasDirectUrl && !hasImetaUrl && hasMagnet) { const confirmed = typeof window !== "undefined" && window.confirm ? window.confirm("You are uploading with a magnet link only.\n\nSince this video is not hosted on a server, it will only be playable as long as you (or others) continue seeding it.\n\nDo you want to proceed?") : true; @@ -758,11 +764,6 @@ export class UploadModal { } } - const nip71Metadata = this.nip71FormManager.collectSection("custom"); - if (nip71Metadata) { - rawPayload.nip71 = nip71Metadata; - } - const { payload, errors } = normalizeVideoNotePayload(rawPayload); if (errors.length) {