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

未关闭 适合新手
#393 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@bhushan4work 已经在做这个了。

开始于 2026年11月6日。

  • #398 来自 @bhushan4work —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
backend

调研方向

从 src/lib/meta-fetcher.ts 中的 parseMetaTags() 开始,查找现有的标题解析测试,包括保留 meta content 内部空白的测试。为标题中的多行和重复 ASCII 空白添加一个会失败的测试,然后检查 meta content 的行为是否保持不变。标题符合浏览器合并空白的行为,并且列出的检查、测试和构建命令均通过,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
8
派生
4
平均合并
8 小时 44 分钟
30 天内合并 PR
159

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

codercops/ogcops 的其他 Issue

查看 codercops/ogcops 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。