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)