Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oembedのjsonにhtmlが含まれてないとエラーになる #20

Open
anatawa12 opened this issue Dec 25, 2023 · 1 comment
Open

oembedのjsonにhtmlが含まれてないとエラーになる #20

anatawa12 opened this issue Dec 25, 2023 · 1 comment

Comments

@anatawa12
Copy link
Member

https://oembed.com/ 曰くhtmlは必須なので、ない方が悪いですがエラーになって取得できませんになってしまいます。

real world example: https://adventar.org/calendars/9018


TypeError: Cannot read properties of undefined (reading 'startsWith')
    at getOEmbedPlayer (file:///Users/anatawa12/IdeaProjects/summaly/built/general.js:43:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 1)
    at async default (file:///Users/anatawa12/IdeaProjects/summaly/built/general.js:194:28)
    at async summaly (file:///Users/anatawa12/IdeaProjects/summaly/built/index.js:37:21)
    at async Object.<anonymous> (file:///Users/anatawa12/IdeaProjects/summaly/built/index.js:54:29)

@yulog
Copy link

yulog commented Mar 17, 2024

今見るとhtmlは含まれるようですが、終端が</iframe>\nとなっています。

{
  "version": "1.0",
  "width": "100%",
  "height": 437,
  "type": "rich",
  "provider_name": "Adventar",
  "provider_url": "https://adventar.org",
  "url": "https://adventar.org/calendars/9018/embed",
  "html": "<iframe src=\"https://adventar.org/calendars/9018/embed\" width=\"100%\" height=\"437\"></iframe>\n"
}

現在のコードだと終端が\nだとoEmbedの対象外になってそうです。

summaly/src/general.ts

Lines 47 to 50 in 71fe234

if (!body.html.startsWith('<iframe ') || !body.html.endsWith('</iframe>')) {
// It includes something else than an iframe
return null;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants