package nex import ( "bufio" "io" "net/url" "strings" "tildegit.org/tjp/sliderule/internal/types" ) // ParseRequest reads a nex request from an io.Reader. func ParseRequest(rdr io.Reader) (*types.Request, error) { line, err := bufio.NewReader(rdr).ReadString('\n') if err != nil { return nil, err } line = strings.TrimSuffix(line, "\n") line = strings.TrimSuffix(line, "\r") u, err := url.Parse("nex:" + line) if err != nil { return nil, err } u.OmitHost = true return &types.Request{URL: u}, nil }