Formatting
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
export async function getWebsiteTitle(url: string): Promise<string | null> {
|
||||
const res = await fetch(url, { redirect: 'follow' })
|
||||
const res = await fetch(url, { redirect: "follow" })
|
||||
|
||||
if (!res.ok) {
|
||||
return null
|
||||
}
|
||||
|
||||
const contentType = res.headers.get('content-type')
|
||||
if (!contentType || !contentType.includes('text/html')) {
|
||||
const contentType = res.headers.get("content-type")
|
||||
if (!contentType || !contentType.includes("text/html")) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -16,16 +16,16 @@ export async function getWebsiteTitle(url: string): Promise<string | null> {
|
||||
|
||||
if (titleMatch && titleMatch[1]) {
|
||||
const title = titleMatch[1]
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/&/g, "&")
|
||||
.replace(/"/g, "\"")
|
||||
.replace(/'/g, "'")
|
||||
.replace(/ /g, ' ')
|
||||
.replace(/ /g, " ")
|
||||
.trim()
|
||||
|
||||
return title || null
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user