fix(route/smartlink): Remove HTML from the title for cnbc (#21130)

This commit is contained in:
Qiang Huang
2026-02-13 16:00:58 +08:00
committed by GitHub
parent 6ab5cf62ff
commit 91ff6e28df
+4 -1
View File
@@ -12,7 +12,10 @@ function parseTitle(smartlinkUrl: string): string {
const dateIndex = pathSegments.findIndex((segment) => dateRegex.test(segment));
// Use the segment after the date if found, otherwise use the last path segment
const titleSlug = dateIndex !== -1 && dateIndex < pathSegments.length - 1 ? pathSegments[dateIndex + 1] : pathSegments.at(-1) || '';
let titleSlug = dateIndex !== -1 && dateIndex < pathSegments.length - 1 ? pathSegments[dateIndex + 1] : pathSegments.at(-1) || '';
// Remove .html/.htm extension if present
titleSlug = titleSlug.replace(/\.(html?|htm)$/i, '');
// Convert hyphens to spaces and capitalize each word
return toTitleCase(titleSlug.replaceAll('-', ' '));