Skip to content

Commit

Permalink
Merge pull request #10 from aflock/support-parens
Browse files Browse the repository at this point in the history
Support parentheses within url
  • Loading branch information
bryanwoods committed Nov 6, 2013
2 parents 3812d87 + 5a0a6b1 commit 4a80913
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions autolink.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ autoLink = (options...) ->
(^|\s) # Capture the beginning of string or leading whitespace
(
(?:https?|ftp):// # Look for a valid URL protocol (non-captured)
[\-A-Z0-9+\u0026@#/%?=~_|!:,.;]* # Valid URL characters (any number of times)
[\-A-Z0-9+\u0026@#/%=~_|] # String must end in a valid URL character
[\-A-Z0-9+\u0026@#/%?=()~_|!:,.;]* # Valid URL characters (any number of times)
[\-A-Z0-9+\u0026@#/%=~()_|] # String must end in a valid URL character
)
///gi

Expand Down
4 changes: 2 additions & 2 deletions autolink.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions test/autolink-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ describe "autolink", ->
"Go here now <a href='http://twitter.com/#!/PostDeskUK'>http://twitter.com/#!/PostDeskUK</a>"
)

it "correctly handles parentheses ()", ->
expect("My favorite Wikipedia Article http://en.wikipedia.org/wiki/Culture_of_honor_(Southern_United_States)".autoLink()).
toEqual(
"My favorite Wikipedia Article <a href='http://en.wikipedia.org/wiki/Culture_of_honor_(Southern_United_States)'>http://en.wikipedia.org/wiki/Culture_of_honor_(Southern_United_States)</a>"
)

it "correctly handles FTP links", ->
expect("Click here ftp://ftp.google.com".autoLink()).
toEqual(
Expand Down
6 changes: 4 additions & 2 deletions test/autolink-spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4a80913

Please sign in to comment.