File tree Expand file tree Collapse file tree
app/src/main/java/to/bitkit/ui/settings/advanced Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -111,20 +111,22 @@ class RgsServerViewModel @Inject constructor(
111111 }
112112
113113 private fun isValidURL (data : String ): Boolean {
114- val pattern = Regex (
114+ // Allow localhost in development mode
115+ if (Env .isDebug && data.contains(" localhost" )) {
116+ return true
117+ }
118+
119+ return URL_PATTERN .matches(data)
120+ }
121+
122+ companion object {
123+ private val URL_PATTERN = Regex (
115124 " ^(https?://)?" + // protocol
116125 " ((([a-z\\ d]([a-z\\ d-]*[a-z\\ d])*)\\ .)+[a-z]{2,}|" + // domain name
117126 " ((\\ d{1,3}\\ .){3}\\ d{1,3}))" + // IP (v4) address
118127 " (:\\ d+)?(/[-a-z\\ d%_.~+]*)*" , // port and path
119128 RegexOption .IGNORE_CASE
120129 )
121-
122- // Allow localhost in development mode
123- if (Env .isDebug && data.contains(" localhost" )) {
124- return true
125- }
126-
127- return pattern.matches(data)
128130 }
129131}
130132
You can’t perform that action at this time.
0 commit comments