(path string)
| 50 | var unsafePathCharsRegexp = regexp.MustCompile(`[\x00-\x1f\x7f-\x9f]+`) |
| 51 | |
| 52 | func CleanPath(path string) string { |
| 53 | path = unsafePathCharsRegexp.ReplaceAllLiteralString(strings.TrimSpace(path), "") |
| 54 | // Clean the path as if it were rooted. This prevents leading parent |
| 55 | // components (including a final "..") from surviving the cleanup. |
| 56 | return strings.TrimPrefix(path2.Clean("/"+path), "/") |
| 57 | } |
| 58 | |
| 59 | func PathExt(name string) string { |
| 60 | ext := path2.Ext(name) |
no outgoing calls