browserslist/browserslist-useragent-regexp

--allowHigherVersions should not match missing gaps between versions

LinqToException opened this issue · 1 comments

Would you like to work on this feature?

  • Check this if you would like to implement a PR, we are more than happy to help you go through the process.

What problem are you trying to solve?

When using --allowHigherVersions, (purposedly) missed browser versions are still matched. For example, chrome 114, chrome 116 also matches chrome 115. Basically, it uses the lowest matching browser version, then allows anything newer.

Real example: Queries that include Firefox ESR and some form of non-ESR Firefox (e.g. last 1 firefox version, Firefox ESR) will produce overmatching regular expressions when called with --allowHigherVersions:

Firefox\/(10[2-9]|1[1-9]\d|[2-9]\d{2}|\d{4,})\.\d+(\.\d+|)

which will match any Firefox >= 102 (the older ESR version), although the last 1 firefox version would be 116.

npx browserslist lists these appropriately:

firefox 115
firefox 102

with 116 being the main one, and 102/115 being ESRs.

Describe the solution you'd like

When using --allowHigherVersions or using another switch, base the "higher versions" on the highest available version, i.e. allow gaps in-between (unless such a behaviour was perhaps explicitly asked for).

In this case, it should be something like 102|11[5-9]|1[2-9]\d|[2-9]\d{2}|\d{4,}

Describe alternatives you've considered

Right now, it would be necessary to keep one regex per "separated browser group". However, since Firefox ESRalready returns firefox 102 and firefox 115, this wouldn't work, and require three manual checks (one against firefox 102, one against firefox 105, and another against the other browsers).

Documentation, Adoption, Migration Strategy

No response

@LinqToException Hi. You can fund me to help me spend more time on this project. It will help me to implement this feature early as possible.