From 8e245a5497c5b3ed6768360c413754e0e094ecf1 Mon Sep 17 00:00:00 2001 From: Enzo Vezzaro Date: Mon, 27 Jun 2022 10:27:06 -0400 Subject: [PATCH] replaced is-url-superb to fix export issue on jest --- package-lock.json | 17 ----------------- package.json | 1 - src/@utils/docker.ts | 2 +- src/@utils/url.ts | 12 ++++++++++++ .../@shared/FormFields/URLInput/index.tsx | 2 +- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 91107224f..c464af5f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,6 @@ "filesize": "^9.0.1", "formik": "^2.2.9", "gray-matter": "^4.0.3", - "is-url-superb": "^6.1.0", "js-cookie": "^3.0.1", "jwt-decode": "^3.1.2", "lodash.debounce": "^4.0.8", @@ -26916,17 +26915,6 @@ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" }, - "node_modules/is-url-superb": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/is-url-superb/-/is-url-superb-6.1.0.tgz", - "integrity": "sha512-LXdhGlYqUPdvEyIhWPEEwYYK3yrUiPcBjmFGlZNv1u5GtIL5qQRf7ddDyPNAvsMFqdzS923FROpTQU97tLe3JQ==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-utf8": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", @@ -62195,11 +62183,6 @@ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" }, - "is-url-superb": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/is-url-superb/-/is-url-superb-6.1.0.tgz", - "integrity": "sha512-LXdhGlYqUPdvEyIhWPEEwYYK3yrUiPcBjmFGlZNv1u5GtIL5qQRf7ddDyPNAvsMFqdzS923FROpTQU97tLe3JQ==" - }, "is-utf8": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", diff --git a/package.json b/package.json index ae0d5dde8..ba206687a 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,6 @@ "filesize": "^9.0.1", "formik": "^2.2.9", "gray-matter": "^4.0.3", - "is-url-superb": "^6.1.0", "js-cookie": "^3.0.1", "jwt-decode": "^3.1.2", "lodash.debounce": "^4.0.8", diff --git a/src/@utils/docker.ts b/src/@utils/docker.ts index 9453f5447..b128e3992 100644 --- a/src/@utils/docker.ts +++ b/src/@utils/docker.ts @@ -1,6 +1,6 @@ import { LoggerInstance } from '@oceanprotocol/lib' import axios from 'axios' -import isUrl from 'is-url-superb' +import { isUrl } from '@utils/url' import { toast } from 'react-toastify' async function isDockerHubImageValid( diff --git a/src/@utils/url.ts b/src/@utils/url.ts index 5fbfe5f43..411bc1aab 100644 --- a/src/@utils/url.ts +++ b/src/@utils/url.ts @@ -8,3 +8,15 @@ export function sanitizeUrl(url: string) { return 'about:blank' return url } + +export function isUrl(string: string) { + let url + + try { + url = new URL(string) + } catch (_) { + return false + } + + return url.protocol === 'http:' || url.protocol === 'https:' +} diff --git a/src/components/@shared/FormFields/URLInput/index.tsx b/src/components/@shared/FormFields/URLInput/index.tsx index 3890032c9..531f51702 100644 --- a/src/components/@shared/FormFields/URLInput/index.tsx +++ b/src/components/@shared/FormFields/URLInput/index.tsx @@ -5,7 +5,7 @@ import Loader from '@shared/atoms/Loader' import styles from './index.module.css' import InputGroup from '@shared/FormInput/InputGroup' import InputElement from '@shared/FormInput/InputElement' -import isUrl from 'is-url-superb' +import { isUrl } from '@utils/url' export default function URLInput({ submitText,