File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed
Message/MessageSimple/utils Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -69,13 +69,20 @@ const styles = StyleSheet.create({
6969
7070const goToURL = ( url ?: string ) => {
7171 if ( ! url ) return ;
72- Linking . canOpenURL ( url ) . then ( ( supported ) => {
73- if ( supported ) {
74- Linking . openURL ( url ) ;
75- } else {
76- console . log ( `Don't know how to open URI: ${ url } ` ) ;
72+ else {
73+ let finalUrl = url ;
74+ const pattern = new RegExp ( / ^ . + \/ \/ / ) ;
75+ if ( ! pattern . test ( url ) ) {
76+ finalUrl = 'http://' + url ;
7777 }
78- } ) ;
78+ Linking . canOpenURL ( finalUrl ) . then ( ( supported ) => {
79+ if ( supported ) {
80+ Linking . openURL ( finalUrl ) ;
81+ } else {
82+ console . log ( `Don't know how to open URI: ${ finalUrl } ` ) ;
83+ }
84+ } ) ;
85+ }
7986} ;
8087
8188export type CardPropsWithContext <
Original file line number Diff line number Diff line change @@ -147,10 +147,16 @@ export const renderText = <
147147 } ,
148148 } ;
149149
150- const onLink = ( url : string ) =>
151- onLinkParams
150+ const onLink = ( url : string ) => {
151+ const pattern = new RegExp ( / ^ .+ \/ \/ / ) ;
152+ if ( ! pattern . test ( url ) ) {
153+ url = 'http://' + url ;
154+ }
155+
156+ return onLinkParams
152157 ? onLinkParams ( url )
153158 : Linking . canOpenURL ( url ) . then ( ( canOpenUrl ) => canOpenUrl && Linking . openURL ( url ) ) ;
159+ } ;
154160
155161 const link : ReactNodeOutput = ( node , output , { ...state } ) => {
156162 const onPress = ( event : GestureResponderEvent ) => {
You can’t perform that action at this time.
0 commit comments