device icon indicating copy to clipboard operation
device copied to clipboard

Allow iPhone to be classed as a 'phone'

Open kgodsmark opened this issue 6 months ago • 0 comments

Some iPhone user agent strings are not matching to 'phone' - as raised in #31.

This PR:

  • adds config to the test case in commit 85d92c941f6b7d7ae5f2dcb3a11f2ac66434a5a4 to avoid the default fallback to 'phone'. The test then fails.

  • adds a condition after all other attempts to match, to match a user agent string including iPhone as 'phone'. The test passes.


The following is how I can now receive 'phone' for iPhone, whilst still receiving null for other unknown strings.

device(
  'Mozilla/5.0 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko)', 
  {unknownUserAgentDeviceType: null}
).type

// 'phone'

kgodsmark avatar Aug 01 '24 10:08 kgodsmark