Skip to content

Commit caca49b

Browse files
committed
Fixed a matching problem and created two tests
1 parent a21e996 commit caca49b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

autolink.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
autoLink = (options...) ->
22
pattern = ///
3-
(^|[\s\S\n]|<br\/?>) # Capture the beginning of string or line or leading whitespace
3+
(^|[\s\n]|<[A-Za-z]*\/?>) # Capture the beginning of string or line or leading whitespace
44
(
55
(?:https?|ftp):// # Look for a valid URL protocol (non-captured)
66
[\-A-Z0-9+\u0026\u2019@#/%?=()~_|!:,.;]* # Valid URL characters (any number of times)

test/autolink-spec.coffee

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ describe "autolink", ->
116116
"<a href='http://google.com'>http://google.com</a> " +
117117
"That is a link to Google"
118118
)
119+
it "can have a hyperlink after a tag", ->
120+
expect("<li>http://google.com</li>".autoLink()).
121+
toEqual(
122+
"<li>" +
123+
"<a href='http://google.com'>http://google.com</a>" +
124+
"</li>"
125+
)
126+
127+
it "can have a hyperlink after two tag", ->
128+
expect("<li><p>http://google.com</p></li>".autoLink()).
129+
toEqual(
130+
"<li><p>" +
131+
"<a href='http://google.com'>http://google.com</a>" +
132+
"</p></li>"
133+
)
119134

120135
describe "callback option", ->
121136
it "can be passed to redefine how link will be rendered", ->

0 commit comments

Comments
 (0)