diff options
author | James Lopez <james@gitlab.com> | 2018-11-02 17:32:05 +0300 |
---|---|---|
committer | James Lopez <james@gitlab.com> | 2018-11-02 17:32:05 +0300 |
commit | ccb706d3466e9643164a86dfd96f582b42926bc6 (patch) | |
tree | aabe691e592d0efdca66436f6bfd8de118cb0994 /lib/gitlab/markup_helper.rb | |
parent | 75917c51f96cd09bade639f85ef6acb708ab4ab2 (diff) |
Refactor MarkupHelper to add INDEX plain filename
Diffstat (limited to 'lib/gitlab/markup_helper.rb')
-rw-r--r-- | lib/gitlab/markup_helper.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/gitlab/markup_helper.rb b/lib/gitlab/markup_helper.rb index 142b7d1a472..e4e90d1d448 100644 --- a/lib/gitlab/markup_helper.rb +++ b/lib/gitlab/markup_helper.rb @@ -4,10 +4,11 @@ module Gitlab module MarkupHelper extend self - MARKDOWN_EXTENSIONS = %w(mdown mkd mkdn md markdown).freeze - ASCIIDOC_EXTENSIONS = %w(adoc ad asciidoc).freeze - OTHER_EXTENSIONS = %w(textile rdoc org creole wiki mediawiki rst).freeze + MARKDOWN_EXTENSIONS = %w[mdown mkd mkdn md markdown].freeze + ASCIIDOC_EXTENSIONS = %w[adoc ad asciidoc].freeze + OTHER_EXTENSIONS = %w[textile rdoc org creole wiki mediawiki rst].freeze EXTENSIONS = MARKDOWN_EXTENSIONS + ASCIIDOC_EXTENSIONS + OTHER_EXTENSIONS + PLAIN_FILENAMES = %w[readme index].freeze # Public: Determines if a given filename is compatible with GitHub::Markup. # @@ -43,7 +44,7 @@ module Gitlab # # Returns boolean def plain?(filename) - extension(filename) == 'txt' || filename.casecmp('readme').zero? + extension(filename) == 'txt' || plain_filename?(filename) end def previewable?(filename) @@ -55,5 +56,9 @@ module Gitlab def extension(filename) File.extname(filename).downcase.delete('.') end + + def plain_filename?(filename) + PLAIN_FILENAMES.include?(filename.downcase) + end end end |