lib/kramdown/parser/kramdown/autolink.rb in kramdown-0.11.0 vs lib/kramdown/parser/kramdown/autolink.rb in kramdown-0.12.0

- old
+ new

@@ -29,21 +29,20 @@ elsif RUBY_VERSION < '1.9.0' ACHARS = '\w' else ACHARS = '[[:alnum:]]' end - AUTOLINK_START_STR = "<((mailto|https?|ftps?):.+?|[-.#{ACHARS}]+@[-#{ACHARS}]+(\.[-#{ACHARS}]+)*\.[a-z]+)>" + AUTOLINK_START_STR = "<((mailto|https?|ftps?):.+?|[-.#{ACHARS}]+@[-#{ACHARS}]+(?:\.[-#{ACHARS}]+)*\.[a-z]+)>" if RUBY_VERSION < '1.9.0' AUTOLINK_START = /#{AUTOLINK_START_STR}/u else AUTOLINK_START = /#{AUTOLINK_START_STR}/ end # Parse the autolink at the current location. def parse_autolink @src.pos += @src.matched_size - href = @src[1] - href= "mailto:#{href}" if @src[2].nil? + href = (@src[2].nil? ? "mailto:#{@src[1]}" : @src[1]) el = Element.new(:a, nil, {'href' => href}) add_text(@src[1].sub(/^mailto:/, ''), el) @tree.children << el end define_parser(:autolink, AUTOLINK_START, '<')