Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse user agent into a human-friendly string on submission #86

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Iterate based on review
  • Loading branch information
t3chguy committed Nov 25, 2024
commit 88866695ed09b565c7c14258e8471f12e9829305
8 changes: 4 additions & 4 deletions submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ func parseJSONRequest(w http.ResponseWriter, req *http.Request, reportDir string
parsed.AppName = p.AppName

if p.UserAgent != "" {
parsed.Data["User-Agent"] = parseUserAgent(p.UserAgent)
parsed.Data["Raw-User-Agent"] = p.UserAgent
parsed.Data["Parsed-User-Agent"] = parseUserAgent(p.UserAgent)
parsed.Data["User-Agent"] = p.UserAgent
}
if p.Version != "" {
parsed.Data["Version"] = p.Version
Expand Down Expand Up @@ -433,8 +433,8 @@ func formPartToPayload(field, data string, p *payload) {
} else if field == "version" {
p.Data["Version"] = data
} else if field == "user_agent" {
p.Data["User-Agent"] = parseUserAgent(data)
p.Data["Raw-User-Agent"] = data
p.Data["User-Agent"] = data
p.Data["Parsed-User-Agent"] = parseUserAgent(data)
} else if field == "label" {
p.Labels = append(p.Labels, data)
} else {
Expand Down
4 changes: 2 additions & 2 deletions submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ func TestParseUserAgent(t *testing.T) {
}

wanted := "Chrome 130.0.6723 on Windows 10 running on Other device"
if p.Data["User-Agent"] != wanted {
t.Errorf("user agent: got %s, want %s", p.Data["User-Agent"], wanted)
if p.Data["Parsed-User-Agent"] != wanted {
t.Errorf("user agent: got %s, want %s", p.Data["Parsed-User-Agent"], wanted)
}
}
Loading