Skip to content
This repository has been archived by the owner on Dec 24, 2019. It is now read-only.

Commit

Permalink
Merge pull request #25 from 18F/joeschanges
Browse files Browse the repository at this point in the history
Joeschanges
  • Loading branch information
maheese authored Sep 10, 2019
2 parents 8ca3972 + 0c901b6 commit b2bf6c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ func init() {
}

func helloHtml(path string) string {
no_foo := convertFoo(path)
return fmt.Sprintf("<h1>Salutations AMPD from Go,</h1>\n<p>You've requested: %s</p>\n", html.EscapeString(no_foo))
}

func convertFoo(path string) string {
re := regexp.MustCompile(`(?i)foo`)
path = re.ReplaceAllString(path, "bar")
return fmt.Sprintf("<h1>Salutations AMPD from Go,</h1>\n<p>You've requested: %s</p>\n", html.EscapeString(path))
return path
}

func main() {
Expand Down
2 changes: 1 addition & 1 deletion src/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit b2bf6c0

Please sign in to comment.