parseURLPath normalizes a URL path by removing query strings and fragments, ensuring it has a leading slash and no trailing slash.
(env string)
| 99 | // parseURLPath normalizes a URL path by removing query strings and fragments, |
| 100 | // ensuring it has a leading slash and no trailing slash. |
| 101 | func parseURLPath(env string) (string, error) { |
| 102 | // Remove query string |
| 103 | if i := strings.IndexByte(env, '?'); i >= 0 { |
| 104 | env = env[:i] |
| 105 | } |
| 106 | // Remove fragment |
| 107 | if i := strings.IndexByte(env, '#'); i >= 0 { |
| 108 | env = env[:i] |
| 109 | } |
| 110 | // Remove trailing slash |
| 111 | if len(env) > 0 && env[len(env)-1] == '/' { |
| 112 | env = env[:len(env)-1] |
| 113 | } |
| 114 | // Ensure leading slash |
| 115 | if len(env) > 0 && env[0] != '/' { |
| 116 | env = "/" + env |
| 117 | } |
| 118 | return env, nil |
| 119 | } |
| 120 | |
| 121 | // parseImageTypes parses a comma-separated list of image format names and returns |
| 122 | // a slice of imagetype.Type values. |
nothing calls this directly
no outgoing calls
no test coverage detected