IsValidPathSegmentName validates the name can be safely encoded as a path segment
(name string)
| 1168 | |
| 1169 | // IsValidPathSegmentName validates the name can be safely encoded as a path segment |
| 1170 | func IsValidPathSegmentName(name string) []string { |
| 1171 | for _, illegalName := range NameMayNotBe { |
| 1172 | if name == illegalName { |
| 1173 | return []string{fmt.Sprintf(`may not be '%s'`, illegalName)} |
| 1174 | } |
| 1175 | } |
| 1176 | |
| 1177 | var errors []string |
| 1178 | for _, illegalContent := range NameMayNotContain { |
| 1179 | if strings.Contains(name, illegalContent) { |
| 1180 | errors = append(errors, fmt.Sprintf(`may not contain '%s'`, illegalContent)) |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | return errors |
| 1185 | } |
| 1186 | |
| 1187 | // IsValidPathSegmentPrefix validates the name can be used as a prefix for a name which will be encoded as a path segment |
| 1188 | // It does not check for exact matches with disallowed names, since an arbitrary suffix might make the name valid |
no outgoing calls
no test coverage detected