Commit 39fc235a authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Allow files with .md.erb for the Static Site Editor

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/223171

We want to extend Static Site Editor functionality to support more
file extensions.
parent 28bef2d8
---
title: Allow files with .md.erb extension for the Static Site Editor
merge_request: 35136
author:
type: added
......@@ -3,7 +3,7 @@
module Gitlab
module StaticSiteEditor
class Config
SUPPORTED_EXTENSIONS = %w[.md].freeze
SUPPORTED_EXTENSIONS = %w[.md .md.erb].freeze
def initialize(repository, ref, file_path, return_url)
@repository = repository
......@@ -42,11 +42,11 @@ module Gitlab
end
def extension_supported?
File.extname(file_path).in?(SUPPORTED_EXTENSIONS)
SUPPORTED_EXTENSIONS.any? { |ext| file_path.end_with?(ext) }
end
def file_exists?
commit_id.present? && repository.blob_at(commit_id, file_path).present?
commit_id.present? && !repository.blob_at(commit_id, file_path).nil?
end
def full_path
......
......@@ -30,6 +30,22 @@ describe Gitlab::StaticSiteEditor::Config do
)
end
context 'when file has .md.erb extension' do
let(:file_path) { 'README.md.erb' }
before do
repository.create_file(
project.creator,
file_path,
'',
message: 'message',
branch_name: 'master'
)
end
it { is_expected.to include(is_supported_content: 'true') }
end
context 'when file path is nested' do
let(:file_path) { 'lib/README.md' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment