Vydané zdroje
Stáhnout zdroje ZIP
CH-J Server Manager
Procházejte adresáře a soubory konkrétního vydání aplikace.
Zdroje jsou zveřejněny pod CH-J Proprietary Software License 1.14. Jejich dostupnost nemění licenční podmínky ani neposkytuje další oprávnění.
1
"use strict";3
function normalizeBaseUrl(value) {4
const url = new URL(String(value || ""));5
if (url.protocol !== "https:") throw new Error("Update URL must use HTTPS.");6
if (url.username || url.password || url.hash || url.search) throw new Error("Invalid update base URL.");7
url.pathname = `${url.pathname.replace(/\/+$/, "")}/`;8
return url;9
}11
function assertAllowedUrl(candidate, allowedBaseUrls, options = {}) {12
const raw = String(candidate || "").trim();13
if (!raw) throw new Error("Missing URL.");14
const bases = allowedBaseUrls.map(normalizeBaseUrl);16
if (raw.startsWith("/")) {17
if (!options.baseUrl) throw new Error("Relative URL requires a base URL.");18
return assertAllowedUrl(new URL(raw.replace(/^\/+/, ""), normalizeBaseUrl(options.baseUrl)).toString(), allowedBaseUrls, options);19
}21
const url = new URL(raw);22
if (url.username || url.password || url.hash) throw new Error("URL credentials and fragments are not allowed.");23
const matchedBase = bases.find((base) => (24
url.protocol === base.protocol25
&& url.hostname === base.hostname26
&& url.port === base.port27
&& url.pathname.startsWith(base.pathname)28
));29
if (!matchedBase) throw new Error("URL is outside the update allowlist.");31
if (options.pathSegment && !url.pathname.startsWith(`${matchedBase.pathname}${options.pathSegment}`)) {32
throw new Error("URL path is outside the allowed update area.");33
}34
return url;35
}37
module.exports = {38
assertAllowedUrl,39
normalizeBaseUrl40
};SHA-256: db15c1e8b5a134391637a8de3efca895dcbf77095a5eaf58acba061b69775030
SHA-256 archivu: 5ac91caf4fa32a6fdb114f2430deed486fbe7489d5eea343d1f034169fafb5e0