stretchr / goweb

A lightweight RESTful web framework for Go
632 stars 61 forks source link

web_context.go's FileExtention also returns query parameters #75

Closed nemosupremo closed 10 years ago

nemosupremo commented 10 years ago

WebContext FileExtention function also returns the query parameters. For example with a path like so: /query.csv?a=b&c=d, the function returns .csv?a=b&c=d, while I would have expected just .csv

I assume the fix is just something like:

func (c *WebContext) FileExtension() string {
        ext := strings.ToLower(path.Ext(c.HttpRequest().URL.RequestURI()))
        if idx := strings.Index("?", ext); idx != -1 {
                ext = ext[:idx]
        }
        return ext
}
matryer commented 10 years ago

Hey - if you could submit a PR that'd be awesome? (see https://github.com/stretchr/goweb/wiki/Development-practices)