Skip to content

Commit

Permalink
issue/910: Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
oobayly committed Sep 23, 2024
1 parent aa6e055 commit ab1e6ff
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/components/InputUrl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@ function validate(url: string, t: TFunction): JSX.Element | undefined {

let error;
const getUrlParams = (url: string) => {
let protocol: string | undefined;
let isLocal = false;

try {
const urlObj = new URL(url);

protocol = urlObj.protocol;
const { protocol, hostname } = urlObj;
// 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);

return { protocol, isLocal };
} catch (err) {
return {};
}

return { protocol, isLocal };
};
const {protocol, isLocal} = getUrlParams(url);
const { protocol, isLocal } = getUrlParams(url);
const isSsl = window.location.protocol === "https:";

if (!protocol) {
Expand Down

0 comments on commit ab1e6ff

Please sign in to comment.