mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-07 00:13:06 +00:00
fix(rln-relay): regex pattern match for extended domains (#2444)
* fix(rln-relay): regex pattern match for extended domains * fix: enable localhost too
This commit is contained in:
parent
57220f4606
commit
52af324f47
@ -322,8 +322,8 @@ proc parseCmdArg*(T: type EthRpcUrl, s: string): T =
|
|||||||
## https://url:port/path?query
|
## https://url:port/path?query
|
||||||
## disallowed patterns:
|
## disallowed patterns:
|
||||||
## any valid/invalid ws or wss url
|
## any valid/invalid ws or wss url
|
||||||
var httpPattern = re2"^(https?:\/\/)(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))"
|
var httpPattern = re2"^(https?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*"
|
||||||
var wsPattern = re2"^(wss?:\/\/)(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))"
|
var wsPattern = re2"^(wss?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*"
|
||||||
if regex.match(s, wsPattern):
|
if regex.match(s, wsPattern):
|
||||||
raise newException(ValueError, "Websocket RPC URL is not supported, Please use an HTTP URL")
|
raise newException(ValueError, "Websocket RPC URL is not supported, Please use an HTTP URL")
|
||||||
if not regex.match(s, httpPattern):
|
if not regex.match(s, httpPattern):
|
||||||
|
|||||||
@ -133,8 +133,8 @@ proc parseCmdArg*(T: type EthRpcUrl, s: string): T =
|
|||||||
## https://url:port/path?query
|
## https://url:port/path?query
|
||||||
## disallowed patterns:
|
## disallowed patterns:
|
||||||
## any valid/invalid ws or wss url
|
## any valid/invalid ws or wss url
|
||||||
var httpPattern = re2"^(https?:\/\/)(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))"
|
var httpPattern = re2"^(https?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*"
|
||||||
var wsPattern = re2"^(wss?:\/\/)(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))"
|
var wsPattern = re2"^(wss?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*"
|
||||||
if regex.match(s, wsPattern):
|
if regex.match(s, wsPattern):
|
||||||
echo "here"
|
echo "here"
|
||||||
raise newException(ValueError, "Websocket RPC URL is not supported, Please use an HTTP URL")
|
raise newException(ValueError, "Websocket RPC URL is not supported, Please use an HTTP URL")
|
||||||
|
|||||||
@ -619,8 +619,8 @@ proc parseCmdArg*(T: type EthRpcUrl, s: string): T =
|
|||||||
## https://url:port/path?query
|
## https://url:port/path?query
|
||||||
## disallowed patterns:
|
## disallowed patterns:
|
||||||
## any valid/invalid ws or wss url
|
## any valid/invalid ws or wss url
|
||||||
var httpPattern = re2"^(https?:\/\/)(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))"
|
var httpPattern = re2"^(https?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*"
|
||||||
var wsPattern = re2"^(wss?:\/\/)(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))"
|
var wsPattern = re2"^(wss?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*"
|
||||||
if regex.match(s, wsPattern):
|
if regex.match(s, wsPattern):
|
||||||
raise newException(ValueError, "Websocket RPC URL is not supported, Please use an HTTP URL")
|
raise newException(ValueError, "Websocket RPC URL is not supported, Please use an HTTP URL")
|
||||||
if not regex.match(s, httpPattern):
|
if not regex.match(s, httpPattern):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user