Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
return null;
}

if (!body.html.startsWith('<iframe ') || !body.html.endsWith('</iframe>')) {
if (typeof body.html !== 'string' || !body.html.startsWith('<iframe ') || !body.html.endsWith('</iframe>')) {
// It includes something else than an iframe
return null;
}
Expand Down Expand Up @@ -146,7 +146,7 @@
const url = typeof _url === 'string' ? new URL(_url) : _url;

const res = await scpaping(url.href, {
lang: lang || undefined,

Check warning on line 149 in src/general.ts

View workflow job for this annotation

GitHub Actions / lint (22.23.2)

typescript(prefer-nullish-coalescing)

src/general.ts:149:14: Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator.
userAgent: opts?.userAgent,
followRedirects: opts?.followRedirects,
responseTimeout: opts?.responseTimeout,
Expand Down Expand Up @@ -174,7 +174,7 @@
const url = typeof _url === 'string' ? new URL(_url) : _url;
const $ = res.$;
const twitterCard =
$('meta[name="twitter:card"]').attr('content') ||

Check warning on line 177 in src/general.ts

View workflow job for this annotation

GitHub Actions / lint (22.23.2)

typescript(prefer-nullish-coalescing)

src/general.ts:177:50: Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator.
$('meta[property="twitter:card"]').attr('content');

// According to docs, name attribute of meta tag is used for twitter card but for compatibility,
Expand Down
6 changes: 6 additions & 0 deletions test/oembed/invalid/oembed-no-html.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "1.0",
"type": "rich",
"width": 500,
"height": 500
}
Loading