Check packfile protocole scheme + rm semicolons

This commit is contained in:
S1m 2021-09-20 08:58:20 +02:00
parent 5d3c7d1e2f
commit e0d895f22a

View File

@ -22,12 +22,10 @@ import * as frequent from "./frequently-used.js"
// then ${PACK_BASE_URL}/${packFile} for each packFile in the packs object of the index.json file. // then ${PACK_BASE_URL}/${packFile} for each packFile in the packs object of the index.json file.
const PACKS_BASE_URL = "packs" const PACKS_BASE_URL = "packs"
let INDEX = `${PACKS_BASE_URL}/index.json`; let INDEX = `${PACKS_BASE_URL}/index.json`
let params = new URLSearchParams(document.location.search); const params = new URLSearchParams(document.location.search)
let REMOTE = false;
if (params.has('config')) { if (params.has('config')) {
INDEX = params.get("config"); INDEX = params.get("config")
REMOTE = true;
} }
// This is updated from packs/index.json // This is updated from packs/index.json
let HOMESERVER_URL = "https://matrix-client.matrix.org" let HOMESERVER_URL = "https://matrix-client.matrix.org"
@ -137,8 +135,8 @@ class App extends Component {
HOMESERVER_URL = indexData.homeserver_url || HOMESERVER_URL HOMESERVER_URL = indexData.homeserver_url || HOMESERVER_URL
// TODO only load pack metadata when scrolled into view? // TODO only load pack metadata when scrolled into view?
for (const packFile of indexData.packs) { for (const packFile of indexData.packs) {
let packRes; let packRes
if (REMOTE) { if (packFile.startsWith("https://") || packFile.startsWith("http://")) {
packRes = await fetch(packFile, { cache }) packRes = await fetch(packFile, { cache })
} else { } else {
packRes = await fetch(`${PACKS_BASE_URL}/${packFile}`, { cache }) packRes = await fetch(`${PACKS_BASE_URL}/${packFile}`, { cache })