Skip to content

Resolves OP-Engineering/link-preview-js#159 - Creates an onResponse c… #170

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

Merged
merged 2 commits into from
May 26, 2025

Conversation

Alpha4615
Copy link
Contributor

This PR:

  • Creates the optional onResponse option that is a callback function that allows the developer to modify the contents of the parsed response body, in the event there needs to be custom logic or sources for different properties. For example, say the targeted website does not provide opengraph description, the developer might want to instead have the description be the text contents of the first p tag. Additionally, an instance of the URL object has been exposed so the callback could contain site-by-site considerations.
  • Creates a test for onResponse functionality.
  • Updates README to provide documentation and use case for onResponse
  • Defines Type ILinkPreviewResponse for the actual library response for type safety.

Tests passed locally (Github CI tests might break due to bot detection)

This PR will resolve #159

@ospfranco ospfranco merged commit c20cad0 into OP-Engineering:main May 26, 2025
1 check failed
@Alpha4615 Alpha4615 deleted the feature/onResponse-override branch May 28, 2025 00:27
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.

Customizable description extensions for better / more reliable descriptions.
2 participants