NewDecoderFromURL - Creates new decoder
(url *url.URL)
| 18 | |
| 19 | // NewDecoderFromURL - Creates new decoder |
| 20 | func NewDecoderFromURL(url *url.URL) (Decoder, error) { |
| 21 | switch url.Scheme { |
| 22 | case "file": |
| 23 | return NewFileDecoder(url.Path), nil |
| 24 | case "http", "https": |
| 25 | if url.Hostname() == "gist.github.com" { |
| 26 | url.Host = "gist.githubusercontent.com" |
| 27 | url.Path = path.Join(url.Path, "/raw") |
| 28 | } |
| 29 | return NewHTTPDecoder(url.String()), nil |
| 30 | case "": |
| 31 | return NewFileDecoder(url.Path), nil |
| 32 | default: |
| 33 | return nil, errors.New("unknown decoder type") |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | // FILE |
| 38 |
no test coverage detected