Reject schemes other than gemini:// in NewRequest

This commit is contained in:
Adnan Maolood
2020-10-27 21:18:05 -04:00
parent 239ec885f7
commit b84811668c
3 changed files with 6 additions and 4 deletions

View File

@@ -45,6 +45,9 @@ func NewRequest(rawurl string) (*Request, error) {
// NewRequestFromURL returns a new request for the given URL.
// The host is inferred from the URL.
func NewRequestFromURL(url *url.URL) (*Request, error) {
if url.Scheme != "" && url.Scheme != "gemini" {
return nil, ErrNotAGeminiURL
}
host := url.Host
if url.Port() == "" {
host += ":1965"