Browse Source

fixed display of "Redirecting..." from opengraph data

imwald
Silberengel 4 months ago
parent
commit
94a02ffd36
  1. 13
      src/services/web.service.ts

13
src/services/web.service.ts

@ -44,9 +44,20 @@ class WebService {
const parser = new DOMParser() const parser = new DOMParser()
const doc = parser.parseFromString(html, 'text/html') const doc = parser.parseFromString(html, 'text/html')
const title = let title =
doc.querySelector('meta[property="og:title"]')?.getAttribute('content') || doc.querySelector('meta[property="og:title"]')?.getAttribute('content') ||
doc.querySelector('title')?.textContent doc.querySelector('title')?.textContent
// Filter out common redirect/loading titles (including variations with ellipsis)
if (title) {
const trimmedTitle = title.trim()
if (/^(Redirecting|Loading|Please wait|Redirect)(\.\.\.|…)?$/i.test(trimmedTitle) ||
trimmedTitle === '...' ||
trimmedTitle === '…') {
title = undefined
}
}
const description = const description =
doc.querySelector('meta[property="og:description"]')?.getAttribute('content') || doc.querySelector('meta[property="og:description"]')?.getAttribute('content') ||
(doc.querySelector('meta[name="description"]') as HTMLMetaElement | null)?.content (doc.querySelector('meta[name="description"]') as HTMLMetaElement | null)?.content

Loading…
Cancel
Save