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

Strings containing links starting with http:// and wrapped in html tags are parsed incorrectly #507

Open
aadil-shaikh-agileinfoways opened this issue Dec 24, 2024 · 2 comments

Comments

@aadil-shaikh-agileinfoways
Copy link

aadil-shaikh-agileinfoways commented Dec 24, 2024

String containing links starting with http:// and wrapped in html tags are parsed incorrectly

Steps to reproduce:

const userInput1= '<a href="www.google.com">Google</a>'
const userInput2= '<a href="https://www.google.com">Google</a>'
      <Linkify>
      {userInput1}     // Works; extracted link='https://www.google.com'  
      {userInput2}    // Fails; extracted link='www.google.com">Google</a>'
      </Linkify>

Any fix for this?

@aadil-shaikh-agileinfoways aadil-shaikh-agileinfoways changed the title Links starting with http:// wrapped in html tags are parsed incorrectly Strings containinglLinks starting with http:// and wrapped in html tags are parsed incorrectly Dec 24, 2024
@aadil-shaikh-agileinfoways aadil-shaikh-agileinfoways changed the title Strings containinglLinks starting with http:// and wrapped in html tags are parsed incorrectly Strings containing links starting with http:// and wrapped in html tags are parsed incorrectly Dec 24, 2024
@nfrasser
Copy link
Owner

nfrasser commented Dec 24, 2024

Hi @aadil-shaikh-agileinfoways, are you using linkify-react for this? I am unable to reproduce:
https://codepen.io/nfrasser/pen/mdOaOmR

Are you using linkifyjs or linkify-string? These do not support parsing HTML by default. You have to use linkify-html, linkify-element, linkify-react. Or you could use another HTML parser plugin before processing text nodes with linkify.

Quick example: https://codepen.io/nfrasser/pen/dyOwOQO

@aadil-shaikh-agileinfoways
Copy link
Author

aadil-shaikh-agileinfoways commented Dec 26, 2024

Sorry I gave a wrong example. I have updated the example in the original post. Can linkify-html help in this case?

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