refactor: simplify code
parent
11f1f62523
commit
c484117657
|
@ -72,17 +72,18 @@ function isValidUrl(str: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleInput() {
|
async function handleInput() {
|
||||||
if (server.startsWith('https://'))
|
const input = server.trim()
|
||||||
server = server.replace('https://', '')
|
if (input.startsWith('https://'))
|
||||||
|
server = input.replace('https://', '')
|
||||||
|
|
||||||
if (server?.length)
|
if (input.length)
|
||||||
displayError = false
|
displayError = false
|
||||||
|
|
||||||
if (
|
if (
|
||||||
isValidUrl(`https://${server.trim()}`)
|
isValidUrl(`https://${input}`)
|
||||||
&& server.trim().match(/^[a-z0-9-]+(\.[a-z0-9-]+)+(:[0-9]+)?$/i)
|
&& input.match(/^[a-z0-9-]+(\.[a-z0-9-]+)+(:[0-9]+)?$/i)
|
||||||
// Do not hide the autocomplete if a result has an exact substring match on the input
|
// Do not hide the autocomplete if a result has an exact substring match on the input
|
||||||
&& !filteredServers.some(s => s.includes(server.trim()))
|
&& !filteredServers.some(s => s.includes(input))
|
||||||
)
|
)
|
||||||
autocompleteShow = false
|
autocompleteShow = false
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue