gitea源码

file_test.go 503B

12345678910111213141516171819202122232425262728
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package files
  4. import (
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestCleanUploadFileName(t *testing.T) {
  9. cases := []struct {
  10. input, expected string
  11. }{
  12. {"", ""},
  13. {".", ""},
  14. {"a/./b", "a/b"},
  15. {"a.git", "a.git"},
  16. {".git/b", ""},
  17. {"a/.git", ""},
  18. {"/a/../../b", "b"},
  19. }
  20. for _, c := range cases {
  21. assert.Equal(t, c.expected, CleanGitTreePath(c.input), "input: %q", c.input)
  22. }
  23. }