Module: Gitlab::FileMarkdownLinkBuilder

Includes:
FileTypeDetection
Included in:
API::Entities::WikiAttachment, UploaderHelper
Defined in:
lib/gitlab/file_markdown_link_builder.rb

Constant Summary

Constants included from FileTypeDetection

Gitlab::FileTypeDetection::DANGEROUS_AUDIO_EXT, Gitlab::FileTypeDetection::DANGEROUS_IMAGE_EXT, Gitlab::FileTypeDetection::DANGEROUS_VIDEO_EXT, Gitlab::FileTypeDetection::PDF_EXT, Gitlab::FileTypeDetection::SAFE_AUDIO_EXT, Gitlab::FileTypeDetection::SAFE_IMAGE_EXT, Gitlab::FileTypeDetection::SAFE_IMAGE_FOR_SCALING_EXT, Gitlab::FileTypeDetection::SAFE_VIDEO_EXT

Instance Method Summary collapse

Methods included from FileTypeDetection

#audio?, #dangerous_audio?, #dangerous_embeddable?, #dangerous_image?, #dangerous_video?, #embeddable?, extension_match?, #image?, #image_safe_for_scaling?, #pdf?, #video?

Instance Method Details


9
10
11
12
13
14
15
# File 'lib/gitlab/file_markdown_link_builder.rb', line 9

def markdown_link
  return unless name = markdown_name

  markdown = "[#{name.gsub(']', '\\]')}](#{secure_url})"
  markdown = "!#{markdown}" if embeddable? || dangerous_embeddable?
  markdown
end

#markdown_nameObject


17
18
19
20
21
# File 'lib/gitlab/file_markdown_link_builder.rb', line 17

def markdown_name
  return unless filename.present?

  embeddable? ? File.basename(filename, File.extname(filename)) : filename
end