Skip to content

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

Merged
ospfranco merged 2 commits intoOP-Engineering:mainfrom
Alpha4615:feature/onResponse-override
May 26, 2025
Merged

Resolves OP-Engineering/link-preview-js#159 - Creates an onResponse c…#170
ospfranco merged 2 commits intoOP-Engineering:mainfrom
Alpha4615:feature/onResponse-override

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