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

fix: support for CDATA in oembed #98

Merged
merged 14 commits into from
Oct 23, 2022
Merged

fix: support for CDATA in oembed #98

merged 14 commits into from
Oct 23, 2022

Conversation

jacktuck
Copy link
Owner

No description provided.

@jacktuck
Copy link
Owner Author

Test

❯ curl "https://unfurljs.herokuapp.com/?url=https://soundcloud.com/the-bugle" -s | jq '.oEmbed'
{
  "version": "1.0",
  "type": "rich",
  "height": 450,
  "width": 100,
  "title": "The Bugle",
  "html": "<iframe width=\"100%\" height=\"450\" scrolling=\"no\" frameborder=\"no\" src=\"https://w.soundcloud.com/player/?visual=true&url=https%3A%2F%2Fapi.soundcloud.com%2Fusers%2F9818871&show_artwork=true\"></iframe>"
}

…/master

* 'master' of github.com:jacktuck/unfurl:
  chore: sort out the lock files
  chore: run tests on all LTS node versions
@jacktuck
Copy link
Owner Author

jacktuck commented Oct 23, 2022

@adrian-seijo let me know what you think. I couldn't resist some refactoring so I'll comment on the relevant line changes.

},
});
{
recognizeCDATA: true,
Copy link
Owner Author

@jacktuck jacktuck Oct 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tells html parser to look for cdata tags

content.html = "";
const parser = new Parser(
{
oncdataend: () => {
Copy link
Owner Author

@jacktuck jacktuck Oct 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we pass recognizeCDATA we can add a oncdataend handler which will get called when the cdata tag closes.

@jacktuck jacktuck changed the base branch from master to next October 23, 2022 03:20
* next:
  Add support for Header options instead of separate userAgent and acceptLanguage options
  Add support for Accept-Language header
@jacktuck jacktuck merged commit 127d61f into next Oct 23, 2022
@jacktuck jacktuck deleted the adrian-seijo/master branch October 23, 2022 03:28
jacktuck added a commit that referenced this pull request Oct 23, 2022
BREAKING CHANGE: changes to parser

* feat: Add support for Accept-Language header
* fix: support for CDATA in oembed (#98)

Co-authored-by @adrian-seijo
Co-authored-by: Stef Kors <stef@beamapp.co>
@adrian-seijo
Copy link

src/index.ts

Definetively a better approach, love that 5 major version bump of the parser 😜 Thanks for the release!

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

Successfully merging this pull request may close these issues.

None yet

2 participants