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

wrong parsing of user agents behind gcp proxy #36

Open
bsafwen opened this issue Jan 19, 2024 · 0 comments
Open

wrong parsing of user agents behind gcp proxy #36

bsafwen opened this issue Jan 19, 2024 · 0 comments

Comments

@bsafwen
Copy link

bsafwen commented Jan 19, 2024

thanks for the lib. This is probably a NIT and a low priority. Just putting it here in case it turns out to be more important that I think.

Accessing a resource hosted on gcp through the gcp proxy makes the library completely miss the browser name:

expected result
https://uaparser.js.org/?ua=cloud-run-proxy/source%20(darwin/arm64)%20Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/537.36%20(KHTML,%20like%20Gecko)%20Chrome/120.0.0.0%20Safari/537.36#try

{
  "ua": "cloud-run-proxy/source (darwin/arm64) Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
  "browser": {
    "name": "Chrome",
    "version": "120.0.0.0",
    "major": "120"
  },
  "cpu": {
    "architecture": "arm64"
  },
  "device": {
    "model": "Macintosh",
    "vendor": "Apple"
  },
  "engine": {
    "name": "Blink",
    "version": "120.0.0.0"
  },
  "os": {
    "name": "macOS",
    "version": "10.15.7"
  }
}

instead got

{
 VersionNo:{Major:0 Minor:0 Patch:0}
 OSVersionNo:{Major:10 Minor:15 Patch:7}
 URL: String:cloud-run-proxy/source (darwin/arm64) Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 
 Name:cloud-run-proxy
 Version:source
 OS:macOS
 OSVersion:10.15.7
 Device:
 Mobile:false
 Tablet:false
 Desktop:true
 Bot:false
 }
package main

import (
	"fmt"

	"github.com/mileusna/useragent"
)

func main() {
	ua := `cloud-run-proxy/source (darwin/arm64) Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36`

	u := useragent.Parse(ua)

	fmt.Printf("%+v\n", u)

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@bsafwen and others