mirror of
https://github.com/BreizhHardware/Jellystat.git
synced 2026-01-18 16:27:20 +01:00
fix to replace is-url-http library due to docker build issues
This commit is contained in:
@@ -436,8 +436,13 @@ class JellyfinAPI {
|
||||
this.#errorHandler(error);
|
||||
return {
|
||||
isValid: false,
|
||||
status: error.response.status ?? 0,
|
||||
errorMessage: error.response != null ? this.#httpErrorMessageHandler(error) : error.message,
|
||||
status: error?.response?.status ?? 0,
|
||||
errorMessage:
|
||||
error?.response != null
|
||||
? this.#httpErrorMessageHandler(error)
|
||||
: error.code == "ENOTFOUND"
|
||||
? "Unable to connect. Please check the URL and your network connection."
|
||||
: error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ const db = require("../db");
|
||||
const jwt = require("jsonwebtoken");
|
||||
const configClass = require("../classes/config");
|
||||
const packageJson = require("../../package.json");
|
||||
const isUrlHttp = require("is-url-http");
|
||||
const JellyfinAPI = require("../classes/jellyfin-api");
|
||||
const Jellyfin = new JellyfinAPI();
|
||||
|
||||
@@ -102,8 +101,8 @@ router.post("/configSetup", async (req, res) => {
|
||||
if (!/^https?:\/\//i.test(_url)) {
|
||||
_url = "http://" + _url;
|
||||
}
|
||||
console.log(_url, isUrlHttp(_url));
|
||||
if (!isUrlHttp(_url)) {
|
||||
console.log(_url, isValidUrl(_url));
|
||||
if (!isValidUrl(_url)) {
|
||||
res.status(400);
|
||||
|
||||
res.send({
|
||||
@@ -141,4 +140,13 @@ router.post("/configSetup", async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
function isValidUrl(string) {
|
||||
try {
|
||||
new URL(string);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -3,7 +3,6 @@ const express = require("express");
|
||||
const { axios } = require("../classes/axios");
|
||||
const configClass = require("../classes/config");
|
||||
const JellyfinAPI = require("../classes/jellyfin-api");
|
||||
const isUrlHttp = require("is-url-http");
|
||||
|
||||
const Jellyfin = new JellyfinAPI();
|
||||
const router = express.Router();
|
||||
@@ -180,8 +179,8 @@ router.post("/validateSettings", async (req, res) => {
|
||||
if (!/^https?:\/\//i.test(_url)) {
|
||||
_url = "http://" + _url;
|
||||
}
|
||||
console.log(_url, isUrlHttp(_url));
|
||||
if (!isUrlHttp(_url)) {
|
||||
console.log(_url, isValidUrl(_url));
|
||||
if (!isValidUrl(_url)) {
|
||||
res.status(400);
|
||||
|
||||
res.send({
|
||||
@@ -198,4 +197,13 @@ router.post("/validateSettings", async (req, res) => {
|
||||
res.send(validation);
|
||||
});
|
||||
|
||||
function isValidUrl(string) {
|
||||
try {
|
||||
new URL(string);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = router;
|
||||
|
||||
1054
package-lock.json
generated
1054
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,7 @@
|
||||
"axios-cache-interceptor": "^1.3.1",
|
||||
"bootstrap": "^5.2.3",
|
||||
"cacheable-lookup": "^6.1.0",
|
||||
"check-valid-url": "^0.1.0",
|
||||
"compare-versions": "^6.0.0-rc.1",
|
||||
"compression": "^1.7.4",
|
||||
"config": "^3.3.9",
|
||||
@@ -46,7 +47,6 @@
|
||||
"i18next-browser-languagedetector": "^7.2.0",
|
||||
"i18next-fs-backend": "^2.3.1",
|
||||
"i18next-http-backend": "^2.4.3",
|
||||
"is-url-http": "^2.3.8",
|
||||
"knex": "^2.4.2",
|
||||
"material-react-table": "^2.12.1",
|
||||
"moment": "^2.29.4",
|
||||
|
||||
Reference in New Issue
Block a user