angular / angular/components

feat(Platform): allow DI override of userAgent

Offen
#33,751 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: cdk/platform feature gemini-triaged needs triage
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### Feature Description

Right now it is hardcoded as global `navigator.userAgent`:
https://github.com/angular/components/blob/main/src/cdk/platform/platform.ts

However in SSR there's a way to get userAgent from the request and accessing global entities is bad practice. Would be great if there was a token for userAgent [like we do here](https://github.com/taiga-family/ng-web-apis/blob/main/libs/common/src/tokens/user-agent.ts), or maybe at least `inject(DOCUMENT).defaultView?.navigator?.userAgent` way of accessing it, rather than just global `navigator.userAgent`

### Use Case

_No response_

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start in src/cdk/platform/platform.ts, where the global navigator.userAgent access is defined, and inspect the surrounding platform injection setup. Compare the requested injectable user-agent source with the existing DOCUMENT access and verify the result in SSR while preserving browser behavior; done means callers can override the user agent through DI.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
68/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.