obipawan / react-native-hyperlink

A <Hyperlink /> component for react-native that makes urls, fuzzy links, emails etc clickable
MIT License
801 stars 76 forks source link

Not linking custom domains #42

Closed ETLopes closed 5 years ago

ETLopes commented 5 years ago

Describe the bug React-native-hyperlink is not linking custom urls. For example "www.trusst.app" does not get linked.

To Reproduce Steps to reproduce the behavior: create a text within the Hyperlink tag with the text www.trusst.app

Expected behavior The text should be clickable and formatted as designed.

Screenshots Image from iOS

Smartphone (please complete the following information): iOS(any) Tested on iphone 6

Additional context

obipawan commented 5 years ago

Hi @ETLopes Thanks for reporting. Hyperlink uses linkify-it to detect patterns.

You need to pass a custom linkify-it object like so,

import { Text } from 'react-native'
import Hyperlink from 'react-native-hyperlink'

export default () =>
<Hyperlink
    onPress={ ... }  
    linkify={ require('linkify-it')().tlds('app', true) } // Add unofficial `.app` domain
>
    <Text>www.trusst.app</Text>
</Hyperlink>