PurpleSec / ParseURL

Golang 'url.Parse' wapper that fixes some of the common formatting and parsing errors

Home Page:https://pkg.go.dev/github.com/PurpleSec/parseurl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ParseURL

ParseURL is a simple wrapper that fixes some of the weird issues that the standard Golang 'url.Parse' function does.

Fixes things such as

  • "localhost:8080"
    • url.Parse: Host == "", Scheme == "localhost:8080"
  • "10.10.10.10/url/"
    • url.Parse: Returns an error <why?>
  • "localhost:"
    • url.Parse: Host == "localhost:" <doesn't strip the ':'>

This package adds in checks for invalid values returned by 'url.Parse' such as the Host field being empty. All non-standard errors wrap the error "ErrInvalidURL" to assist in indication of the error.

This library is a drop-in replacement for the "url.Parse" function. Just import "github.com/PurpleSec/parseurl" and go!

About

Golang 'url.Parse' wapper that fixes some of the common formatting and parsing errors

https://pkg.go.dev/github.com/PurpleSec/parseurl

License:Apache License 2.0


Languages

Language:Go 100.0%