File tree Expand file tree Collapse file tree 4 files changed +49
-6
lines changed Expand file tree Collapse file tree 4 files changed +49
-6
lines changed Original file line number Diff line number Diff line change @@ -332,9 +332,9 @@ var linkedText = Autolinker.link( input, {
332
332
}
333
333
334
334
case ' phone' :
335
- console .log ( " Phone Number: " , match .getNumber () );
335
+ console .log ( " Phone Number: " , match .getPhoneNumber () );
336
336
337
- return ' <a href="http://newplace.to.link.phone.numbers.to/">' + match .getNumber () + ' </a>' ;
337
+ return ' <a href="http://newplace.to.link.phone.numbers.to/">' + match .getPhoneNumber () + ' </a>' ;
338
338
339
339
case ' mention' :
340
340
console .log ( " Mention: " , match .getMention () );
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ import { MentionMatcher } from "./matcher/mention-matcher";
91
91
* }
92
92
*
93
93
* case 'phone' :
94
- * var phoneNumber = match.getNumber ();
94
+ * var phoneNumber = match.getPhoneNumber ();
95
95
* console.log( phoneNumber );
96
96
*
97
97
* return '<a href="http://newplace.to.link.phone.numbers.to/">' + phoneNumber + '</a>';
Original file line number Diff line number Diff line change @@ -58,18 +58,31 @@ export class PhoneMatch extends Match {
58
58
59
59
60
60
/**
61
- * Returns the phone number that was matched as a string, without any
62
- * delimiter characters.
61
+ * Returns the phone number that was matched as a string, without any
62
+ * delimiter characters.
63
63
*
64
64
* Note: This is a string to allow for prefixed 0's.
65
65
*
66
66
* @return {String }
67
67
*/
68
- getNumber ( ) {
68
+ getPhoneNumber ( ) {
69
69
return this . number ;
70
70
}
71
71
72
72
73
+ /**
74
+ * Alias of {@link #getPhoneNumber}, returns the phone number that was
75
+ * matched as a string, without any delimiter characters.
76
+ *
77
+ * Note: This is a string to allow for prefixed 0's.
78
+ *
79
+ * @return {String }
80
+ */
81
+ getNumber ( ) {
82
+ return this . getPhoneNumber ( ) ;
83
+ }
84
+
85
+
73
86
/**
74
87
* Returns the anchor href that should be generated for the match.
75
88
*
Original file line number Diff line number Diff line change 1
1
import { PhoneMatcher } from "../../src/matcher/phone-matcher" ;
2
2
import { AnchorTagBuilder } from "../../src/anchor-tag-builder" ;
3
3
import { MatchChecker } from "../match/match-checker" ;
4
+ import { PhoneMatch } from "../../src" ;
4
5
5
6
describe ( "Autolinker.matcher.Phone" , function ( ) {
6
7
let matcher : PhoneMatcher ;
@@ -64,4 +65,33 @@ describe( "Autolinker.matcher.Phone", function() {
64
65
} ) ;
65
66
66
67
68
+ describe ( 'getPhoneNumber()' , function ( ) {
69
+
70
+ it ( `should should return the matched phone number without any
71
+ formatting` ,
72
+ ( ) => {
73
+ let matches = matcher . parseMatches ( 'Talk to (123) 456-7890' ) ;
74
+
75
+ expect ( matches . length ) . toBe ( 1 ) ;
76
+ expect ( matches [ 0 ] ) . toEqual ( jasmine . any ( PhoneMatch ) ) ;
77
+ expect ( ( matches [ 0 ] as PhoneMatch ) . getPhoneNumber ( ) ) . toBe ( '1234567890' ) ;
78
+ } ) ;
79
+
80
+ } ) ;
81
+
82
+
83
+ describe ( 'getNumber()' , function ( ) {
84
+
85
+ it ( `as an alias of getPhoneNumber(), should return the matched phone
86
+ number, without any formatting` ,
87
+ ( ) => {
88
+ let matches = matcher . parseMatches ( 'Talk to (123) 456-7890' ) ;
89
+
90
+ expect ( matches . length ) . toBe ( 1 ) ;
91
+ expect ( matches [ 0 ] ) . toEqual ( jasmine . any ( PhoneMatch ) ) ;
92
+ expect ( ( matches [ 0 ] as PhoneMatch ) . getNumber ( ) ) . toBe ( '1234567890' ) ;
93
+ } ) ;
94
+
95
+ } ) ;
96
+
67
97
} ) ;
You can’t perform that action at this time.
0 commit comments