issue/910: Fix linting errors

This commit is contained in:
John Bayly
2024-09-23 16:16:51 +01:00
parent aa6e05532e
commit ab1e6ffd8f
+7 -10
View File
@@ -11,21 +11,18 @@ function validate(url: string, t: TFunction): JSX.Element | undefined {
let error; let error;
const getUrlParams = (url: string) => { const getUrlParams = (url: string) => {
let protocol: string | undefined;
let isLocal = false;
try { try {
const urlObj = new URL(url); const urlObj = new URL(url);
const { protocol, hostname } = urlObj;
protocol = urlObj.protocol;
// Basic check against localhost; 127.0.0.1/8 and IPv6 localhost [::1] // Basic check against localhost; 127.0.0.1/8 and IPv6 localhost [::1]
isLocal = /^(localhost|\[::1\]|127(.[0-9]{1,3}){3})/i.test(urlObj.hostname); const isLocal = /^(localhost|\[::1\]|127(.[0-9]{1,3}){3})/i.test(hostname);
} catch (err) {
}
return { protocol, isLocal }; return { protocol, isLocal };
} catch (err) {
return {};
}
}; };
const {protocol, isLocal} = getUrlParams(url); const { protocol, isLocal } = getUrlParams(url);
const isSsl = window.location.protocol === "https:"; const isSsl = window.location.protocol === "https:";
if (!protocol) { if (!protocol) {