extractTemplateVariables extracts template variables from a URL string e.g., "http://{host}:{port}/mcp" returns ["host", "port"]
(url string)
| 33 | // extractTemplateVariables extracts template variables from a URL string |
| 34 | // e.g., "http://{host}:{port}/mcp" returns ["host", "port"] |
| 35 | func extractTemplateVariables(url string) []string { |
| 36 | re := regexp.MustCompile(`\{([^}]+)\}`) |
| 37 | matches := re.FindAllStringSubmatch(url, -1) |
| 38 | |
| 39 | var variables []string |
| 40 | for _, match := range matches { |
| 41 | if len(match) > 1 { |
| 42 | variables = append(variables, match[1]) |
| 43 | } |
| 44 | } |
| 45 | return variables |
| 46 | } |
| 47 | |
| 48 | // replaceTemplateVariables replaces template variables with placeholder values for URL validation |
| 49 | func replaceTemplateVariables(rawURL string) string { |
no outgoing calls
no test coverage detected
searching dependent graphs…