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

Url detected by the library but considered as invalid by URL native module #506

Open
Apokalypt opened this issue Dec 15, 2024 · 0 comments
Assignees
Labels
bug parsing Related to string parsing

Comments

@Apokalypt
Copy link

I use the library to detect, in messages, URLs used to scam people. However, today, the detection failed on a message due to an invalid library detection preventing a parse by nodejs' native URL library

Code

function findURLs(text: string): URL[] {
    return linkify.find(text, "url")
        .map( l => new URL(l.href) );
}

const messageWithTwoUrls = "[https://store.steampowered.com](https://u.com/aig)"
const res = findURLs(messageWithTwoUrls) // <- error thrown by new URL

Url detected

[{
  "type": "url",
  "value": "https://store.steampowered.com](https://u.com/aig)",
  "isLink": true,
  "href": "https://store.steampowered.com](https://u.com/aig)"
}]

Expected

[{
  "type": "url",
  "value": "https://store.steampowered.com",
  "isLink": true,
  "href": "https://store.steampowered.com"
},{
  "type": "url",
  "value": "https://u.com/aig",
  "isLink": true,
  "href": "https://u.com/aig"
}]
@nfrasser nfrasser self-assigned this Dec 24, 2024
@nfrasser nfrasser added parsing Related to string parsing bug labels Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug parsing Related to string parsing
Projects
None yet
Development

No branches or pull requests

2 participants