diff --git a/ZMediumToMarkdown.gemspec b/ZMediumToMarkdown.gemspec index 215bbe8..f92e5d0 100644 --- a/ZMediumToMarkdown.gemspec +++ b/ZMediumToMarkdown.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |gem| gem.files = Dir['lib/**/*.*'] gem.executables = ['ZMediumToMarkdown'] gem.name = 'ZMediumToMarkdown' - gem.version = '2.1.5' + gem.version = '2.1.7' gem.license = "MIT" diff --git a/lib/Parsers/MarkupStyleRender.rb b/lib/Parsers/MarkupStyleRender.rb index c624bb0..1e6da46 100644 --- a/lib/Parsers/MarkupStyleRender.rb +++ b/lib/Parsers/MarkupStyleRender.rb @@ -197,28 +197,30 @@ def parse() elsif markup.anchorType == "USER" url = "https://medium.com/u/#{markup.userId}" end - - lastPath = url.split("/").last - lastQuery = nil - if !lastPath.nil? - lastQuery = lastPath.split("-").last - end - - if !usersPostURLs.nil? && !usersPostURLs.find { |usersPostURL| usersPostURL.split("/").last.split("-").last == lastQuery }.nil? - if isForJekyll - url = "(../#{lastQuery}/)" - else - url = "(#{lastPath})" + + if url =~ /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}(:[0-9]{1,5})?(\/.*)?$/ix + lastPath = url.split("/").last + lastQuery = nil + if !lastPath.nil? + lastQuery = lastPath.split("-").last end - else - if isForJekyll - url = "(#{url}){:target=\"_blank\"}" + + if !usersPostURLs.nil? && !usersPostURLs.find { |usersPostURL| usersPostURL.split("/").last.split("-").last == lastQuery }.nil? + if isForJekyll + url = "(../#{lastQuery}/)" + else + url = "(#{lastPath})" + end else - url = "(#{url})" + if isForJekyll + url = "(#{url}){:target=\"_blank\"}" + else + url = "(#{url})" + end end + + tag = TagChar.new(1, markup.start, markup.end, "[", "]#{url}") end - - tag = TagChar.new(1, markup.start, markup.end, "[", "]#{url}") else Helper.makeWarningText("Undefined Markup Type: #{markup.type}.") end