diff --git a/src/main.go b/src/main.go index 1842817..1970bca 100644 --- a/src/main.go +++ b/src/main.go @@ -16,9 +16,14 @@ func init() { } func helloHtml(path string) string { + no_foo := convertFoo(path) + return fmt.Sprintf("
You've requested: %s
\n", html.EscapeString(no_foo)) +} + +func convertFoo(path string) string { re := regexp.MustCompile(`(?i)foo`) path = re.ReplaceAllString(path, "bar") - return fmt.Sprintf("You've requested: %s
\n", html.EscapeString(path)) + return path } func main() { diff --git a/src/main_test.go b/src/main_test.go index 185bf01..44ffa99 100644 --- a/src/main_test.go +++ b/src/main_test.go @@ -54,7 +54,7 @@ func TestJavaScriptInjection(t *testing.T) { func TestConvertFoo(t *testing.T) { path := "/foo/bar" - text := helloHtml(path) + text := convertFoo(path) if strings.Contains(text, "foo") { t.Fatal("'foo' in path") }