From a0f3fe7b6f1ec604783c55e9922f074e3aae7d96 Mon Sep 17 00:00:00 2001 From: KillariDev <13102010+KillariDev@users.noreply.github.com> Date: Sun, 28 Jan 2024 17:12:09 +0200 Subject: [PATCH] Update app/ts/components/Settings.tsx Co-authored-by: Micah Zoltu --- app/ts/components/Settings.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/ts/components/Settings.tsx b/app/ts/components/Settings.tsx index 08e7ec1..49347b7 100644 --- a/app/ts/components/Settings.tsx +++ b/app/ts/components/Settings.tsx @@ -35,7 +35,15 @@ export const SettingsModal = ({ display, appSettings }: { display: Signal submissionRelayEndpointInput.value.valid && simulationRelayEndpointInput.value.valid && priorityFeeInput.value.valid && blocksInFutureInput.value.valid) // https://urlregex.com/ - const matchUrl = (value: string) => value.match(/(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/g) + const uriMatcher = new RegExp( + '^https?' + // protocol + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name + '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR IP (v4) address + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path + '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string + '(\\#[-a-z\\d_]*)?$' // fragment locator + ) + const matchUrl = (value: string) => value.match(uriMatcher) function validateSimulationRelayEndpointInput(value: string) { const matched = matchUrl(value)