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

String not recognized #41

Closed
infojunkie opened this issue Jun 20, 2017 · 6 comments
Closed

String not recognized #41

infojunkie opened this issue Jun 20, 2017 · 6 comments

Comments

@infojunkie
Copy link

infojunkie commented Jun 20, 2017

The following string iTunes:bit.ly/oaKTSQ does not get linkified whereas iTunes: bit.ly/oaKTSQ does. It's a bit ambiguous of course, but do you suggest any option to support it?

@pablolmiranda
Copy link

if you add a protocol prefix it should work just fine: http://bit.ly/oaKTSQ or https://bit.ly/oaKTSQ

@infojunkie
Copy link
Author

Thanks, but I don't control the strings to be linkified - I get them from user input.

@pablolmiranda
Copy link

@infojunkie, the domains without a scheme are detected using node-tlds.
bit.ly doesn't match any TLDs on that list, that's why we don't detect it as a valid URL.
Could you parse the user input and add the scheme to the bit.ly URLs ?

const text = userInput.replace(/(bit.ly\/\w+)/g, 'http://$1')

@infojunkie
Copy link
Author

infojunkie commented Aug 30, 2017

Sorry but I don't think I understand your explanation:

  • I checked that my version of node-tlds is 1.192.0 which already includes the TLD ly
  • Notice how bit.ly/oaKTSQ is actually recognized provided there's a space after the : colon

@pablolmiranda
Copy link

Ok, I got it.
The scheme Itunes:bit.ly doesn't qualify as a valid schema and linkify-it module doesn't understand it.
If you use itunes://bit.ly/1234, this will be possible to support since it could be a valid URL schema. But for my understanding, this will not trigger the desired behavior on your side.
I will suggest to you open an issue for linkify-it asking how they can support the URL schema you need.

@tasti tasti mentioned this issue Jan 6, 2018
16 tasks
@tasti
Copy link
Owner

tasti commented Jan 7, 2018

@infojunkie - As mentioned above, you should see if this can be resolved through linkify-it.

Additionally, you'll have the flexibility to support this on your own in v1.0.0. For example:

const matchDecorator = (text) => {
  // Implement your matching logic here to support iTunes:bit.ly/oaKTSQ
};

<Linkify matchDecorator={matchDecorator}>
  ...
</Linkify>

matchDecorator lets you override the default linkify-it logic to match URLs however you'd like.

Any feedback is appreciated.

@tasti tasti closed this as completed Jan 7, 2018
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

3 participants