(c *Context)
| 779 | } |
| 780 | |
| 781 | func redirectTrailingSlash(c *Context) { |
| 782 | req := c.Request |
| 783 | p := req.URL.Path |
| 784 | if prefix := path.Clean(c.Request.Header.Get("X-Forwarded-Prefix")); prefix != "." { |
| 785 | prefix = sanitizePathChars(prefix) |
| 786 | prefix = removeRepeatedChar(prefix, '/') |
| 787 | |
| 788 | p = prefix + "/" + req.URL.Path |
| 789 | } |
| 790 | req.URL.Path = p + "/" |
| 791 | if length := len(p); length > 1 && p[length-1] == '/' { |
| 792 | req.URL.Path = p[:length-1] |
| 793 | } |
| 794 | redirectRequest(c) |
| 795 | } |
| 796 | |
| 797 | // sanitizePathChars removes unsafe characters from path strings, |
| 798 | // keeping only ASCII letters, ASCII numbers, forward slashes, and hyphens. |
no test coverage detected