Skip to content

Commit 29f7d19

Browse files
committed
make simpler regex for detecting prefix
1 parent 16695d7 commit 29f7d19

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Autolinker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ var Autolinker = {
3636

3737
/**
3838
* @private
39-
* @property {RegExp} httpRegex
39+
* @property {RegExp} prefixRegex
4040
*
4141
* A regular expression used to remove the 'http://' or 'https://' and/or the 'www.' from URLs.
4242
*/
43-
httpRegex: /(https?:\/\/)?(www\.)?/g,
43+
prefixRegex: /^(https?:\/\/)?(www\.)?/,
4444

4545

4646
/**
@@ -109,7 +109,7 @@ var Autolinker = {
109109
}
110110

111111
if ( stripPrefix ) {
112-
anchorText = anchorText.replace( Autolinker.httpRegex, '' );
112+
anchorText = anchorText.replace( Autolinker.prefixRegex, '' );
113113
}
114114

115115
// Set the attributes for the anchor tag

Autolinker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Autolinker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ var Autolinker = {
2727

2828
/**
2929
* @private
30-
* @property {RegExp} httpRegex
30+
* @property {RegExp} prefixRegex
3131
*
3232
* A regular expression used to remove the 'http://' or 'https://' and/or the 'www.' from URLs.
3333
*/
34-
httpRegex: /(https?:\/\/)?(www\.)?/g,
34+
prefixRegex: /^(https?:\/\/)?(www\.)?/,
3535

3636

3737
/**
@@ -100,7 +100,7 @@ var Autolinker = {
100100
}
101101

102102
if ( stripPrefix ) {
103-
anchorText = anchorText.replace( Autolinker.httpRegex, '' );
103+
anchorText = anchorText.replace( Autolinker.prefixRegex, '' );
104104
}
105105

106106
// Set the attributes for the anchor tag

0 commit comments

Comments
 (0)