Improve variable names in example code

These were inherited from the JS version of the example, which concerns HTML.
This commit is contained in:
Chris Smowton
2020-09-29 16:36:07 +01:00
parent 3dde501b54
commit 1cfad846c8
2 changed files with 4 additions and 4 deletions

View File

@@ -3,8 +3,8 @@ package main
import "regexp"
func broken(hostNames []byte) string {
var htmlRe = regexp.MustCompile("\bforbidden.host.org")
if htmlRe.Match(hostNames) {
var hostRe = regexp.MustCompile("\bforbidden.host.org")
if hostRe.Match(hostNames) {
return "Must not target forbidden.host.org"
} else {
// This will be reached even if hostNames is exactly "forbidden.host.org",

View File

@@ -3,8 +3,8 @@ package main
import "regexp"
func fixed(hostNames []byte) string {
var htmlRe = regexp.MustCompile("\\bforbidden.host.org")
if htmlRe.Match(hostNames) {
var hostRe = regexp.MustCompile("\\bforbidden.host.org")
if hostRe.Match(hostNames) {
return "Must not target forbidden.host.org"
} else {
// hostNames definitely doesn't contain a word "forbidden.host.org", as "\\b"