fix: use "latest-lts.svrjs" or "latest.svrjs" file from SVR.JS downloads server instead of scraping the SVR.JS website

This commit is contained in:
Dorian Niemiec 2024-09-21 06:51:30 +02:00
parent 8563c69268
commit 5fbf844aee
2 changed files with 7 additions and 11 deletions

View file

@ -18,9 +18,9 @@ if(!version) {
console.log(" '3.6.4' -> SVR.JS 3.6.4");
} else if(version == "latest" || version == "lts") {
https.get({
hostname: "svrjs.org",
hostname: "downloads.svrjs.org",
port: 443,
path: "/",
path: version == "lts" ? "/latest-lts.svrjs" : "/latest.svrjs",
method: "GET",
headers: {
"User-Agent": "create-svrjs-server"
@ -35,16 +35,12 @@ if(!version) {
data += chunk;
});
res.on("end", function() {
var regex = />Download SVR\.JS ([^ <]+)<\/a>/;
if(version == "lts") {
regex = />Download SVR\.JS ([^ <]+) LTS<\/a>/;
}
var dlver = data.match(regex);
var dlver = data.trim();
if(!dlver) {
console.log("Can't obtain the latest version from main page");
console.log("Can't obtain the latest version from downloads server");
} else {
console.log("Selected SVR.JS " + dlver[1]);
downloadSVRJS(dlver[1]);
console.log("Selected SVR.JS " + dlver);
downloadSVRJS(dlver);
}
});
}).on("error", function() {

View file

@ -1,6 +1,6 @@
{
"name": "svrjs",
"version": "3.14.5-stub1",
"version": "4.0.0-stub1",
"description": "A web server running on Node.JS",
"main": "index.js",
"scripts": {