go-rfc3986/unreserved.go

26 lines
429 B
Go
Raw Normal View History

2023-10-06 16:28:51 +00:00
package rfc3986
import (
2024-08-24 14:05:17 +00:00
"github.com/reiver/go-rfc2234"
2023-10-06 16:28:51 +00:00
)
// IsUnreserved returns true if the value of 'r' matches 'unreserved' as defined in IETF RFC-3986:
//
// unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
func IsUnreserved(r rune) bool {
if rfc2234.IsAlpha(r) {
return true
}
2024-08-24 15:53:20 +00:00
if IsDigit(r) {
2023-10-06 16:28:51 +00:00
return true
}
switch r {
case '-' , '.' , '_' , '~':
return true
}
return false
}