chore: more modular link preview generation

This commit is contained in:
Adhiraj Singh
2022-05-27 13:30:37 +05:30
parent 3eeded66b2
commit 15761ca9df
3 changed files with 18 additions and 9 deletions

View File

@@ -28,9 +28,10 @@ export const getUrlInfo = async(
try {
const { getLinkPreview } = await import('link-preview-js')
let previewLink = text
if (!text.startsWith('https://') && !text.startsWith('http://')) {
if(!text.startsWith('https://') && !text.startsWith('http://')) {
previewLink = 'https://' + previewLink
}
const info = await getLinkPreview(previewLink, { timeout: opts.timeoutMs })
if(info && 'title' in info) {
const [image] = info.images