mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-28 11:45:15 +00:00
Adds an API POST endpoint under `/repos/{owner}/{repo}/file-contents` which receives a list of paths and returns a list of the contents of these files. This API endpoint will be helpful for applications like headless CMS (reference: https://github.com/sveltia/sveltia-cms/issues/198) which need to retrieve a large number of files by reducing the amount of needed API calls. Close #33495 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
27 lines
610 B
Go
27 lines
610 B
Go
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package files
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCleanUploadFileName(t *testing.T) {
|
|
t.Run("Clean regular file", func(t *testing.T) {
|
|
name := "this/is/test"
|
|
cleanName := CleanUploadFileName(name)
|
|
expectedCleanName := name
|
|
assert.Equal(t, expectedCleanName, cleanName)
|
|
})
|
|
|
|
t.Run("Clean a .git path", func(t *testing.T) {
|
|
name := "this/is/test/.git"
|
|
cleanName := CleanUploadFileName(name)
|
|
expectedCleanName := ""
|
|
assert.Equal(t, expectedCleanName, cleanName)
|
|
})
|
|
}
|