list-fetch
Advanced tools
Comparing version 27.0.4 to 27.0.5
26
index.js
@@ -65,11 +65,6 @@ module.exports = async function makeBTFetch (opts = {}) { | ||
function htmlIden(data){ | ||
if(data.id.length === 64){ | ||
data.kind = 'address' | ||
if(data.address){ | ||
data.link = `<a href='bt://${data.address}/'>${data.address}</a>` | ||
} else if(data.id.length === 40){ | ||
data.kind = 'infohash' | ||
} else if(data.infohash){ | ||
data.link = `<a href='bt://${data.infohash}/'>${data.infohash}</a>` | ||
} else if(data.id.length === 20){ | ||
data.kind = 'title' | ||
data.link = `<a href='bt://${data.infohash}/'>${data.infohash}</a>` | ||
} | ||
@@ -80,11 +75,6 @@ return `<p>${JSON.stringify(data)}</p>` | ||
function jsonIden(data){ | ||
if(data.id.length === 64){ | ||
data.kind = 'address' | ||
if(data.address){ | ||
data.link = `bt://${data.address}/` | ||
} else if(data.id.length === 40){ | ||
data.kind = 'infohash' | ||
} else if(data.infohash){ | ||
data.link = `bt://${data.infohash}/` | ||
} else if(data.id.length === 20){ | ||
data.kind = 'title' | ||
data.link = `bt://${data.infohash}/` | ||
} | ||
@@ -138,6 +128,6 @@ return data | ||
const torrentData = await app.torrentData(JSON.parse(reqHeaders.get('x-data') || searchParams.get('x-data'))) | ||
return sendTheData(signal, {status: 200, headers: {'X-Length': `${torrentData.length}`}, body: ''}) | ||
return sendTheData(signal, {status: 200, headers: {'X-Length': `${torrentData.size}`, 'X-Count': `${torrentData.length}`}, body: ''}) | ||
} else { | ||
const torrentData = await app.authorData() | ||
return sendTheData(signal, {status: 200, headers: {'X-Length': `${torrentData.length}`}, body: ''}) | ||
return sendTheData(signal, {status: 200, headers: {'X-Length': `${torrentData.size}`, 'X-Count': `${torrentData.length}`}, body: ''}) | ||
} | ||
@@ -208,6 +198,6 @@ } else { | ||
const torrentData = await app.torrentData(JSON.parse(reqHeaders.get('x-data') || searchParams.get('x-data'))) | ||
return sendTheData(signal, {status: 200, headers: {'Content-Type': mainRes}, body: mainReq ? `<html><head><title>${mid.mainLink}</title></head><body><div>${torrentData.length ? torrentData.map(htmlIden) : '<p>there are no data</p>'}</div></body></html>` : JSON.stringify(torrentData.map(jsonIden))}) | ||
return sendTheData(signal, {status: 200, headers: {'Content-Type': mainRes}, body: mainReq ? `<html><head><title>${mid.mainLink}</title></head><body><div>${torrentData.map(htmlIden)}</div></body></html>` : JSON.stringify(torrentData.map(jsonIden))}) | ||
} else { | ||
const torrentData = await app.authorData() | ||
return sendTheData(signal, {status: 200, headers: {'Content-Type': mainRes}, body: mainReq ? `<html><head><title>${mid.mainLink}</title></head><body><div>${torrentData.length ? torrentData.map((data) => {if(data.address){data.link = `<a href='bt://${data.address}/'>${data.address}</a>`} else {data.link = `<a href='bt://${data.infohash}/'>${data.infohash}</a>`} return `<p>${JSON.stringify(data)}</p>`;}) : '<p>there are no data</p>'}</div></body></html>` : JSON.stringify(torrentData.map((data) => {if(data.address){data.link = `bt://${data.address}/`} else {data.link = `bt://${data.infohash}/`} return data;}))}) | ||
return sendTheData(signal, {status: 200, headers: {'Content-Type': mainRes}, body: mainReq ? `<html><head><title>${mid.mainLink}</title></head><body><div>${torrentData.map(htmlIden)}</div></body></html>` : JSON.stringify(torrentData.map(jsonIden))}) | ||
} | ||
@@ -214,0 +204,0 @@ } else { |
{ | ||
"name": "list-fetch", | ||
"version": "27.0.4", | ||
"version": "27.0.5", | ||
"description": "coming soon", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
20548
309