mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-21 03:39:54 +00:00
fix(tui): keep x status citation fallbacks link-like
This commit is contained in:
@@ -30,6 +30,12 @@ describe('external link helpers', () => {
|
||||
).toBe('From Fajardo Icacos Island Full Day Catamaran Trip')
|
||||
})
|
||||
|
||||
it('keeps x.com status fallbacks link-like instead of generic Status labels', () => {
|
||||
expect(urlSlugTitleLabel('https://x.com/grok/status/2056065022749479209')).toBe(
|
||||
'x.com/grok/status/2056065022749479209'
|
||||
)
|
||||
})
|
||||
|
||||
it('normalizes scheme-less links', () => {
|
||||
expect(normalizeExternalUrl(' expedia.com/things-to-do/puerto-rico-el-yunque ')).toBe(
|
||||
'https://expedia.com/things-to-do/puerto-rico-el-yunque'
|
||||
|
||||
@@ -21,6 +21,8 @@ const DOMAIN_RE = /^(?:www\.)?[a-z0-9](?:[a-z0-9-]*\.)+[a-z]{2,}(?::\d+)?(?:[/?#
|
||||
const SKIP_PROTO_RE = /^(?:file|data|mailto|javascript|blob|chrome|about|hermes):/i
|
||||
const LOCAL_HOSTNAME_RE = /^(?:localhost|localhost\.localdomain)$/i
|
||||
const LOCAL_HOST_SUFFIXES = ['.corp', '.home', '.internal', '.lan', '.local', '.localdomain']
|
||||
const STATUS_PERMALINK_HOST_RE = /^(?:mobile\.)?(?:x|twitter)\.com$/i
|
||||
const STATUS_PERMALINK_PATH_RE = /^\/[^/]+\/status\/\d+\/?$/i
|
||||
|
||||
const HTML_ENTITIES: Record<string, string> = {
|
||||
'#39': "'",
|
||||
@@ -101,6 +103,10 @@ function cleanSlug(segment: string): string {
|
||||
export function urlSlugTitleLabel(value: string): string {
|
||||
const url = parseUrl(value)
|
||||
|
||||
if (url && STATUS_PERMALINK_HOST_RE.test(url.hostname) && STATUS_PERMALINK_PATH_RE.test(url.pathname)) {
|
||||
return hostPathLabel(value)
|
||||
}
|
||||
|
||||
for (const segment of url?.pathname.split('/').filter(Boolean).reverse() ?? []) {
|
||||
const cleaned = cleanSlug(segment)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user