本站源代码
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

24 lines
630B

  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.package repofiles
  4. package repofiles
  5. import (
  6. "path"
  7. "strings"
  8. )
  9. // CleanUploadFileName Trims a filename and returns empty string if it is a .git directory
  10. func CleanUploadFileName(name string) string {
  11. // Rebase the filename
  12. name = strings.Trim(path.Clean("/"+name), " /")
  13. // Git disallows any filenames to have a .git directory in them.
  14. for _, part := range strings.Split(name, "/") {
  15. if strings.ToLower(part) == ".git" {
  16. return ""
  17. }
  18. }
  19. return name
  20. }
上海开阖软件有限公司 沪ICP备12045867号-1