Skip to content

fix: prevent panic in ShowBanner when update check regex finds no match #9

Description

@amirhossein-karimi

Bug: ShowBanner panics when update check regex finds no match

Description

Running fallparams against a URL can cause a runtime panic:

go run . -u "https://varzesh3.com"

output
panic: runtime error: index out of range [1] with length 0

goroutine 1 [running]:
github.com/ImAyrix/fallparams/funcs/utils.ShowBanner(...)
funcs/utils/utils.go:61
main.main()
main.go:73
exit status 2

suggest fix
matches := re.FindStringSubmatch(body)

msg := fmt.Sprintf("an %soutdated%s", colorRed, colorReset)

if len(matches) > 1 && matches[1] == version {
    msg = fmt.Sprintf("the %slatest%s", colorGreen, colorReset)
}


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions