53
53
*
54
54
* If the configuration options do not provide enough flexibility, a {@link #replaceFn}
55
55
* may be provided to fully customize the output of Autolinker. This function is
56
- * called once for each URL/Email/Phone#/Hashtag/Mention (Twitter, Instagram)
56
+ * called once for each URL/Email/Phone#/Hashtag/Mention (Twitter, Instagram, Soundcloud )
57
57
* match that is encountered.
58
58
*
59
59
* For example:
60
60
*
61
- * var input = "..."; // string with URLs, Email Addresses, Phone #s, Hashtags, and Mentions (Twitter, Instagram)
61
+ * var input = "..."; // string with URLs, Email Addresses, Phone #s, Hashtags, and Mentions (Twitter, Instagram, Soundcloud )
62
62
*
63
63
* var linkedText = Autolinker.link( input, {
64
64
* replaceFn : function( match ) {
@@ -143,7 +143,7 @@ var Autolinker = function( cfg ) {
143
143
144
144
// Validate the value of the `mention` cfg
145
145
var mention = this . mention ;
146
- if ( mention !== false && mention !== 'twitter' && mention !== 'instagram' ) {
146
+ if ( mention !== false && mention !== 'twitter' && mention !== 'instagram' && mention !== 'soundcloud' ) {
147
147
throw new Error ( "invalid `mention` cfg - see docs" ) ;
148
148
}
149
149
@@ -318,6 +318,7 @@ Autolinker.prototype = {
318
318
*
319
319
* - 'twitter'
320
320
* - 'instagram'
321
+ * - 'soundcloud'
321
322
*
322
323
* Defaults to `false` to skip auto-linking of mentions.
323
324
*/
@@ -444,7 +445,7 @@ Autolinker.prototype = {
444
445
* - Phone links will have the CSS classes: "myLink myLink-phone"
445
446
* - Hashtag links will have the CSS classes: "myLink myLink-hashtag"
446
447
* - Mention links will have the CSS classes: "myLink myLink-mention myLink-[type]"
447
- * where [type] is either "instagram" or "twitter "
448
+ * where [type] is either "instagram", "twitter" or "soundcloud "
448
449
*/
449
450
450
451
/**
@@ -772,7 +773,7 @@ Autolinker.prototype = {
772
773
773
774
/**
774
775
* Automatically links URLs, Email addresses, Phone numbers, Hashtags,
775
- * and Mentions (Twitter, Instagram) found in the given chunk of HTML. Does not link
776
+ * and Mentions (Twitter, Instagram, Soundcloud ) found in the given chunk of HTML. Does not link
776
777
* URLs found within HTML tags.
777
778
*
778
779
* For instance, if given the text: `You should go to http://www.yahoo.com`,
@@ -2342,7 +2343,7 @@ Autolinker.htmlParser.TextNode = Autolinker.Util.extend( Autolinker.htmlParser.H
2342
2343
*
2343
2344
* For example:
2344
2345
*
2345
- * var input = "..."; // string with URLs, Email Addresses, and Mentions (Twitter, Instagram)
2346
+ * var input = "..."; // string with URLs, Email Addresses, and Mentions (Twitter, Instagram, Soundcloud )
2346
2347
*
2347
2348
* var linkedText = Autolinker.link( input, {
2348
2349
* replaceFn : function( match ) {
@@ -2850,7 +2851,7 @@ Autolinker.match.Mention = Autolinker.Util.extend( Autolinker.match.Match, {
2850
2851
2851
2852
/**
2852
2853
* Returns the configured {@link #serviceName} to point the mention to.
2853
- * Ex: 'instagram', 'twitter'.
2854
+ * Ex: 'instagram', 'twitter', 'soundcloud' .
2854
2855
*
2855
2856
* @return {String }
2856
2857
*/
@@ -2870,6 +2871,8 @@ Autolinker.match.Mention = Autolinker.Util.extend( Autolinker.match.Match, {
2870
2871
return 'https://twitter.com/' + this . mention ;
2871
2872
case 'instagram' :
2872
2873
return 'https://instagram.com/' + this . mention ;
2874
+ case 'soundcloud' :
2875
+ return 'https://soundcloud.com/' + this . mention ;
2873
2876
2874
2877
default : // Shouldn't happen because Autolinker's constructor should block any invalid values, but just in case.
2875
2878
throw new Error ( 'Unknown service name to point mention to: ' , this . serviceName ) ;
@@ -3479,7 +3482,8 @@ Autolinker.matcher.Mention = Autolinker.Util.extend( Autolinker.matcher.Matcher,
3479
3482
*/
3480
3483
matcherRegexes : {
3481
3484
"twitter" : new RegExp ( '@[_' + Autolinker . RegexLib . alphaNumericCharsStr + ']{1,20}' , 'g' ) ,
3482
- "instagram" : new RegExp ( '@[_.' + Autolinker . RegexLib . alphaNumericCharsStr + ']{1,50}' , 'g' )
3485
+ "instagram" : new RegExp ( '@[_.' + Autolinker . RegexLib . alphaNumericCharsStr + ']{1,50}' , 'g' ) ,
3486
+ "soundcloud" : new RegExp ( '@[_.' + Autolinker . RegexLib . alphaNumericCharsStr + "\-" + ']{1,50}' , 'g' )
3483
3487
} ,
3484
3488
3485
3489
/**
0 commit comments