|
|
2 лет назад | |
|---|---|---|
| .. | ||
| .gitignore | 2 лет назад | |
| .golangci.yml | 2 лет назад | |
| GRAMMAR | 2 лет назад | |
| LICENSE.md | 2 лет назад | |
| README.md | 2 лет назад | |
| uri.go | 2 лет назад | |
Package uri is meant to be an RFC 3986 compliant URI builder, parser and validator for golang.
It supports strict RFC validation for URI and URI relative references.
u, err := Parse("https://example.com:8080/path")
if err != nil {
fmt.Printf("Invalid URI")
} else {
fmt.Printf("%s", u.Scheme())
}
// Output: https
u, err := ParseReference("//example.com/path")
if err != nil {
fmt.Printf("Invalid URI reference")
} else {
fmt.Printf("%s", u.Authority().Path())
}
// Output: /path
isValid := IsURI("urn://example.com?query=x#fragment/path") // true
isValid= IsURI("//example.com?query=x#fragment/path") // false
isValid= IsURIReference("//example.com?query=x#fragment/path") // true
(to be continued...)
Internationalization support:
IPv6 addressing scheme reference and erratum:
This allows for stricter conformance than the net/url in the Go standard libary,
which provides a workable but loose implementation of the RFC.
This package concentrates on RFC 3986 strictness for URI validation. At the moment, there is no attempt to normalize or auto-escape strings. For url normalization, see PuerkitoBio/purell.
Not supported:
Hostnames vs domain names:
Example:
Tests have been aggregated from test suites of URI validators from other languages: Perl, Python, Scala, .Net. and the Go url standard library.
This package was initially based on the work from ttacon/uri (credits: Trey Tacon). Extra features like MySQL URIs present in the original repo have been removed.
A lot of improvements have been brought by the incredible guys at fyne-io. Thanks all.