@@ -27,11 +27,11 @@ import {
27
27
TextProps ,
28
28
} from 'react-native' ;
29
29
import * as Truncate from './truncate' ;
30
- import { Matchers , MatcherId , LatLngMatch } from './matchers' ;
31
30
import { CustomMatch , CustomMatcher } from './CustomMatch' ;
32
31
import { PropsOf } from './types' ;
33
32
34
33
export * from './CustomMatch' ;
34
+ export * from './matchers' ;
35
35
36
36
const tagBuilder = new AnchorTagBuilder ( ) ;
37
37
@@ -45,7 +45,6 @@ interface AutolinkProps<C extends React.ComponentType = React.ComponentType> {
45
45
component ?: C ;
46
46
email ?: boolean ;
47
47
hashtag ?: false | 'facebook' | 'instagram' | 'twitter' ;
48
- latlng ?: boolean ;
49
48
linkProps ?: TextProps ;
50
49
linkStyle ?: StyleProp < TextStyle > ;
51
50
matchers ?: CustomMatcher [ ] ;
@@ -102,7 +101,6 @@ export default class Autolink<C extends React.ComponentType = typeof Text> exten
102
101
static defaultProps = {
103
102
email : true ,
104
103
hashtag : false ,
105
- latlng : false ,
106
104
linkProps : { } ,
107
105
mention : false ,
108
106
phone : true ,
@@ -187,16 +185,6 @@ export default class Autolink<C extends React.ComponentType = typeof Text> exten
187
185
return [ match . getMatchedText ( ) ] ;
188
186
}
189
187
}
190
- case 'latlng' : {
191
- const latlng = ( match as LatLngMatch ) . getLatLng ( ) ;
192
- const query = latlng . replace ( / \s / g, '' ) ;
193
-
194
- return [
195
- Platform . OS === 'ios'
196
- ? `http://maps.apple.com/?q=${ encodeURIComponent ( latlng ) } &ll=${ query } `
197
- : `https://www.google.com/maps/search/?api=1&query=${ query } ` ,
198
- ] ;
199
- }
200
188
case 'mention' : {
201
189
const username = ( match as MentionMatch ) . getMention ( ) ;
202
190
@@ -225,12 +213,8 @@ export default class Autolink<C extends React.ComponentType = typeof Text> exten
225
213
return [ `tel:${ number } ` ] ;
226
214
}
227
215
}
228
- case 'userCustom' :
229
- case 'url' : {
230
- return [ match . getAnchorHref ( ) ] ;
231
- }
232
216
default : {
233
- return [ match . getMatchedText ( ) ] ;
217
+ return [ match . getAnchorHref ( ) ?? match . getAnchorText ( ) ] ;
234
218
}
235
219
}
236
220
}
@@ -264,7 +248,6 @@ export default class Autolink<C extends React.ComponentType = typeof Text> exten
264
248
component = Text ,
265
249
email,
266
250
hashtag,
267
- latlng,
268
251
linkProps,
269
252
linkStyle,
270
253
matchers = [ ] ,
@@ -318,26 +301,6 @@ export default class Autolink<C extends React.ComponentType = typeof Text> exten
318
301
} ,
319
302
} ) ;
320
303
321
- // Custom matchers
322
- Matchers . forEach ( ( matcher ) => {
323
- // eslint-disable-next-line react/destructuring-assignment
324
- if ( this . props [ matcher . id as MatcherId ] ) {
325
- linkedText = linkedText . replace ( matcher . regex , ( ...args ) => {
326
- const token = generateToken ( ) ;
327
- const matchedText = args [ 0 ] ;
328
-
329
- matches [ token ] = new matcher . Match ( {
330
- tagBuilder,
331
- matchedText,
332
- offset : args [ args . length - 2 ] ,
333
- [ matcher . id as MatcherId ] : matchedText ,
334
- } ) ;
335
-
336
- return token ;
337
- } ) ;
338
- }
339
- } ) ;
340
-
341
304
// User-specified custom matchers
342
305
matchers . forEach ( ( matcher ) => {
343
306
linkedText = linkedText . replace ( matcher . pattern , ( ...replacerArgs ) => {
0 commit comments