Skip to content

feat(lenovo): add broad 'Lenovo TB' prefix for modern tablets#1013

Merged
serbanghita merged 1 commit into4.8.xfrom
feat/lenovo-tb-broad-match
Apr 17, 2026
Merged

feat(lenovo): add broad 'Lenovo TB' prefix for modern tablets#1013
serbanghita merged 1 commit into4.8.xfrom
feat/lenovo-tb-broad-match

Conversation

@serbanghita
Copy link
Copy Markdown
Owner

Summary

  • Adds Lenovo TB| catch-all prefix to the LenovoTablet regex, matching all modern Lenovo tablets that use TB-XXXX (hyphenated) or TBXXXFU (non-hyphenated) naming formats
  • Eliminates the need to individually list every new Lenovo tablet model code — 20+ models from 2023-2026 are now automatically covered
  • Adds 5 test fixtures for recent models not individually listed (TB330FU, TB370FU, TB351FU, TB321FU, TB311XU)

Context

Addresses PR #994 ("Add new 'Lenovo TB' user-agent" by @nstwfdev) and related issues #871, #855. Newer Lenovo tablets were not detected because the existing regex only matched Lenovo TAB (old naming) or specific model codes. This change adds the missing Lenovo TB broad prefix while keeping all existing individual entries intact.

Lenovo tablet naming conventions

Era UA Format Example Matched by
Pre-2016 Lenovo TAB ... Lenovo TAB 2 A7-30F Lenovo TAB (existing)
2016-2022 Lenovo TB-XXXX Lenovo TB-J606F Individual model codes (existing)
2022+ Lenovo TBXXXFU Lenovo TB330FU Lenovo TB (new)

False positive risk

Minimal — a UA containing Lenovo TB is virtually always a Lenovo tablet. The prefix is always followed by either a hyphen+model code or a numeric model code.

Test plan

  • All 1877 existing tests pass
  • 5 new test fixtures for models only matched by the broad prefix
  • phpcs lint passes
  • Review regex change in src/MobileDetect.php line 567

Add 'Lenovo TB|' catch-all to the LenovoTablet regex to match all
modern Lenovo tablets using the TB-XXXX and TBXXXFU naming formats.
This replaces the need to individually list every new model code.

Addresses PR #994 and related issues #871, #855 where newer Lenovo
tablets were not detected because only specific model codes were listed.

Add 5 test fixtures for recent models (TB330FU, TB370FU, TB351FU,
TB321FU, TB311XU) that are only matched by the new broad prefix.
Copilot AI review requested due to automatic review settings April 16, 2026 09:09
@serbanghita serbanghita self-assigned this Apr 16, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands Lenovo tablet detection by adding a broad Lenovo TB prefix to the LenovoTablet tablet-regex, so modern Lenovo tablet model strings (e.g., TB-XXXX and TB###FU) are classified as tablets without needing to enumerate every new model code.

Changes:

  • Update LenovoTablet detection regex to include a broad Lenovo TB prefix.
  • Add 5 new Lenovo tablet UA fixtures (TB330FU, TB370FU, TB351FU, TB321FU, TB311XU).
  • Regenerate tests/ualist.json (including its hash) to reflect the updated provider fixtures.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/MobileDetect.php Adds Lenovo TB to the LenovoTablet detection pattern to cover newer Lenovo tablet UA formats.
tests/providers/vendors/Lenovo.php Adds 5 new Lenovo tablet UA fixtures expected to be matched by the new broad prefix.
tests/ualist.json Updates generated UA fixture list and hash to remain in sync with provider fixtures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@serbanghita
Copy link
Copy Markdown
Owner Author

I feel tiny bit of unconfortable to allow a broad regex like Lenovo TB, but as long as there are tests we're gucci

@serbanghita serbanghita merged commit 5d9742c into 4.8.x Apr 17, 2026
7 checks passed
@serbanghita serbanghita deleted the feat/lenovo-tb-broad-match branch April 17, 2026 18:12
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

Successfully merging this pull request may close these issues.

2 participants