mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-21 17:05:22 +03:00
refactor: simplify code
This commit is contained in:
parent
11f1f62523
commit
c484117657
1 changed files with 7 additions and 6 deletions
|
@ -72,17 +72,18 @@ function isValidUrl(str: string) {
|
|||
}
|
||||
|
||||
async function handleInput() {
|
||||
if (server.startsWith('https://'))
|
||||
server = server.replace('https://', '')
|
||||
const input = server.trim()
|
||||
if (input.startsWith('https://'))
|
||||
server = input.replace('https://', '')
|
||||
|
||||
if (server?.length)
|
||||
if (input.length)
|
||||
displayError = false
|
||||
|
||||
if (
|
||||
isValidUrl(`https://${server.trim()}`)
|
||||
&& server.trim().match(/^[a-z0-9-]+(\.[a-z0-9-]+)+(:[0-9]+)?$/i)
|
||||
isValidUrl(`https://${input}`)
|
||||
&& 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
|
||||
&& !filteredServers.some(s => s.includes(server.trim()))
|
||||
&& !filteredServers.some(s => s.includes(input))
|
||||
)
|
||||
autocompleteShow = false
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue