Skip to content

Commit

Permalink
Fix URLs that get linkified but are missing a scheme (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
bencollab authored and cooperka committed Jul 16, 2017
1 parent c13edf4 commit f9ecf23
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/MessageText.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
import ParsedText from 'react-native-parsed-text';
import Communications from 'react-native-communications';

const WWW_URL_PATTERN = /^www\./i;

export default class MessageText extends React.Component {
constructor(props) {
super(props);
Expand All @@ -20,7 +22,11 @@ export default class MessageText extends React.Component {
}

onUrlPress(url) {
Linking.openURL(url);
if (url.match(WWW_URL_PATTERN)) {
this.onUrlPress('http://' + url);
} else if (Linking.canOpenURL(url)) {
Linking.openURL(url);
}
}

onPhonePress(phone) {
Expand Down

0 comments on commit f9ecf23

Please sign in to comment.