Preview checker: a `<title>` written over several lines keeps its line break and indentation

Offen Anfängerfreundlich
#393 1 Kommentar 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@bhushan4work arbeitet bereits daran.

Seit 06.11.2026.

  • #398 von @bhushan4work — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
84/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
backend

Rechercherichtung

Beginne mit parseMetaTags() in src/lib/meta-fetcher.ts und finde die vorhandenen Tests zur Titelverarbeitung, einschließlich des Tests, der interne Leerzeichen in Meta-content erhält. Füge einen fehlschlagenden Test für mehrzeilige und wiederholte ASCII-Leerzeichen in Titeln hinzu und prüfe anschließend, dass sich das Verhalten von Meta-content nicht geändert hat. Als abgeschlossen gilt die Aufgabe, wenn der Titel dem Zusammenfassen von Leerzeichen durch den Browser entspricht und die aufgeführten Prüf-, Test- und Build-Befehle erfolgreich sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug good first issue

parseMetaTags() in src/lib/meta-fetcher.ts only trims the ends of the <title> text (decodeEntities(titleMatch[1].trim())), so a title written over several lines keeps the line break and the indentation in the middle. Browsers strip and collapse that whitespace (document.title gives Cutting cold starts in half with Fluid Compute | Acme Blog), but the checker keeps it:

parseMetaTags(`<title>
              Cutting cold starts in half with Fluid Compute
              | Acme Blog
      </title>`, 'https://example.com').title
// "Cutting cold starts in half with Fluid Compute\n              | Acme Blog"

That 58-character title gets "Title is 72 chars (recommended: under 70)" from analyzeMeta(), and the Google Search preview (resolvePlatformPreviews() in src/lib/platform-specs.ts) cuts it at 60 characters in the middle of the whitespace, so | Acme Blog never shows.

What to do

  • After decoding entities, collapse each run of ASCII whitespace (space, tab, newline, carriage return, form feed) in the title to one space and strip it from both ends, the way document.title does. &nbsp; isn't ASCII whitespace, so it stays.
  • Leave meta content values as they are. They keep their inner whitespace on purpose (the "trims decoded meta content while preserving internal whitespace" test).

Acceptance criteria

  • The title above comes out as Cutting cold starts in half with Fluid Compute | Acme Blog, and tabs or double spaces inside a title collapse the same way
  • Meta content values and every existing parseMetaTags test stay as they are
  • A test that fails on the current code
  • npm run check, npm run test and npm run build pass

Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #NUM in the description.

Vorherrschende Sprache
TypeScript
Sterne
8
Forks
4
Ø Merge
8 Std. 44 Min.
Gemergte PRs (30 T.)
159

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus codercops/ogcops

Alle Issues in codercops/ogcops

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

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