1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2024-11-22 08:07:30 +00:00

Update instances parser

This commit is contained in:
Cadence Ember 2020-06-19 20:21:29 +12:00
parent e4e190f97e
commit b439158cbc
No known key found for this signature in database
GPG Key ID: 128B99B1B74A6412

View File

@ -30,14 +30,17 @@ module.exports = [
/** [empty, address, country, rss, privacy policy, cloudflare] */
const parts = line.split("|")
if (parts.length >= 6 && parts[1].includes("://")) {
const address = parts[1].trim().split(" ")[0]
let address = parts[1].trim().split(" ")[0]
let match
if (match = address.match(/^\[\S+\]\((\S+)\)$/)) address = match[1]
instances.push({
address,
country: parts[2].match(/[A-Z]{2,}|$/)[0] || null,
official: address === "https://bibliogram.art", // yeah we're just gonna hard code this
rss_enabled: parts[3].trim() !== "",
has_privacy_policy: parts[4].trim() !== "",
using_cloudflare: parts[5].trim() !== ""
using_cloudflare: parts[5].trim() !== "",
onion_site: address.endsWith(".onion")
})
}
} else {
@ -52,7 +55,7 @@ module.exports = [
contentType: "application/json",
content: {
status: "ok",
version: "2.0",
version: "2.1",
generatedAt: Date.now(),
data: result
}