From 4e26594fcb03c378222d2316a004c291d48dd6c7 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Mon, 12 Mar 2018 10:21:20 -0400 Subject: Removed mssola/user_agent library (#8417) * Removed mssola/user_agent library * Changed user agent tests to use t.Run --- api/admin.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'api') diff --git a/api/admin.go b/api/admin.go index 3b58650cc..6016e48f3 100644 --- a/api/admin.go +++ b/api/admin.go @@ -7,10 +7,10 @@ import ( "net/http" "strconv" + "github.com/avct/uasurfer" "github.com/gorilla/mux" "github.com/mattermost/mattermost-server/app" "github.com/mattermost/mattermost-server/model" - "github.com/mssola/user_agent" ) func (api *API) InitAdmin() { @@ -201,12 +201,11 @@ func downloadComplianceReport(c *Context, w http.ResponseWriter, r *http.Request w.Header().Del("Content-Type") // Content-Type will be set automatically by the http writer // attach extra headers to trigger a download on IE, Edge, and Safari - ua := user_agent.New(r.UserAgent()) - bname, _ := ua.Browser() + ua := uasurfer.Parse(r.UserAgent()) w.Header().Set("Content-Disposition", "attachment;filename=\""+job.JobName()+".zip\"") - if bname == "Edge" || bname == "Internet Explorer" || bname == "Safari" { + if ua.Browser.Name == uasurfer.BrowserIE || ua.Browser.Name == uasurfer.BrowserSafari { // trim off anything before the final / so we just get the file's name w.Header().Set("Content-Type", "application/octet-stream") } -- cgit v1.2.3-1-g7c22