From ee32e59eb7f50cfdd51e25705e0ccb12d1d23bc7 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Thu, 21 Mar 2024 12:34:44 -0500 Subject: [PATCH] Add error message for tor urls --- public/i18n/en.json | 1 + src/routes/settings/Servers.tsx | 62 +++++++++++++++++++++++++++++---- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/public/i18n/en.json b/public/i18n/en.json index 7cc74f2e..6a1b66fb 100644 --- a/public/i18n/en.json +++ b/public/i18n/en.json @@ -504,6 +504,7 @@ "storage_label": "Storage", "storage_caption": "Encrypted VSS backup service.", "error_lsp": "That doesn't look like a URL", + "error_tor": "Tor URLs are not currently supported", "save": "Save" }, "nostr_contacts": { diff --git a/src/routes/settings/Servers.tsx b/src/routes/settings/Servers.tsx index caf15673..13fc82b7 100644 --- a/src/routes/settings/Servers.tsx +++ b/src/routes/settings/Servers.tsx @@ -1,4 +1,4 @@ -import { createForm, url } from "@modular-forms/solid"; +import { createForm, custom, url } from "@modular-forms/solid"; import { createResource, Match, Suspense, Switch } from "solid-js"; import { @@ -24,6 +24,26 @@ import { } from "~/logic/mutinyWalletSetup"; import { eify } from "~/utils"; +const validateNotTorUrl = async (value?: string) => { + if (!value) { + return false; + } + + // if it is one of the default URLs, it's safe + // need this handling for self-hosting deployments + if ( + value === import.meta.env.VITE_PROXY || + value === import.meta.env.VITE_ESPLORA || + value === import.meta.env.VITE_RGS || + value === import.meta.env.VITE_LSP || + value === import.meta.env.VITE_STORAGE + ) { + return true; + } + + return !value.includes(".onion"); +}; + function SettingsStringsEditor(props: { initialSettings: MutinyWalletSettingStrings; }) { @@ -54,7 +74,13 @@ function SettingsStringsEditor(props: {
{(field, props) => ( {(field, props) => ( {(field, props) => ( {(field, props) => ( {(field, props) => (