(u *url.URL)
| 128 | } |
| 129 | |
| 130 | func (sr *sinkRegistry) newFileSinkFromURL(u *url.URL) (Sink, error) { |
| 131 | if u.User != nil { |
| 132 | return nil, fmt.Errorf("user and password not allowed with file URLs: got %v", u) |
| 133 | } |
| 134 | if u.Fragment != "" { |
| 135 | return nil, fmt.Errorf("fragments not allowed with file URLs: got %v", u) |
| 136 | } |
| 137 | if u.RawQuery != "" { |
| 138 | return nil, fmt.Errorf("query parameters not allowed with file URLs: got %v", u) |
| 139 | } |
| 140 | // Error messages are better if we check hostname and port separately. |
| 141 | if u.Port() != "" { |
| 142 | return nil, fmt.Errorf("ports not allowed with file URLs: got %v", u) |
| 143 | } |
| 144 | if hn := u.Hostname(); hn != "" && hn != "localhost" { |
| 145 | return nil, fmt.Errorf("file URLs must leave host empty or use localhost: got %v", u) |
| 146 | } |
| 147 | |
| 148 | return sr.newFileSinkFromPath(u.Path) |
| 149 | } |
| 150 | |
| 151 | func (sr *sinkRegistry) newFileSinkFromPath(path string) (Sink, error) { |
| 152 | switch path { |
nothing calls this directly
no test coverage detected