Skip to content

Commit

Permalink
Robustify markdown link formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Lavender committed Sep 22, 2015
1 parent dc20b91 commit 0b036cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/slack-notifier/link_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def html_pattern
end

def markdown_pattern
/\[(.*?)\]\((.+?)\)/
/\[([^\[\]]*?)\]\((https?:\/\/.*?)\)/
end

end
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/slack-notifier/link_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
expect( formatted ).to include("<http://example.com|this>")
end

it "formats markdown links in brackets" do
formatted = described_class.format("Hello World, enjoy [[this](http://example.com) in brackets].")
expect( formatted ).to eq("Hello World, enjoy [<http://example.com|this> in brackets].")
end

it "formats markdown links with no title" do
formatted = described_class.format("Hello World, enjoy [](http://example.com).")
expect( formatted ).to include("<http://example.com>")
Expand Down

0 comments on commit 0b036cf

Please sign in to comment.