summaryrefslogtreecommitdiff
path: root/doc/articles/wiki/final.go
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2013-12-03 09:43:15 +0100
committerMichael Stapelberg <stapelberg@debian.org>2013-12-03 09:43:15 +0100
commit64d2a7c8945ba05af859901f5e248f1befdd8621 (patch)
tree013fcb7e9e3296ecdda876012252c36bd6bcb063 /doc/articles/wiki/final.go
parentb901efe83e212f0c34c769c079e41373da12d723 (diff)
downloadgolang-64d2a7c8945ba05af859901f5e248f1befdd8621.tar.gz
Imported Upstream version 1.2upstream/1.2
Diffstat (limited to 'doc/articles/wiki/final.go')
-rw-r--r--doc/articles/wiki/final.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/doc/articles/wiki/final.go b/doc/articles/wiki/final.go
index e93cdee47..f15794d66 100644
--- a/doc/articles/wiki/final.go
+++ b/doc/articles/wiki/final.go
@@ -67,18 +67,16 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
}
}
-const lenPath = len("/view/")
-
-var titleValidator = regexp.MustCompile("^[a-zA-Z0-9]+$")
+var validPath = regexp.MustCompile("^/(edit|save|view)/([a-zA-Z0-9]+)$")
func makeHandler(fn func(http.ResponseWriter, *http.Request, string)) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
- title := r.URL.Path[lenPath:]
- if !titleValidator.MatchString(title) {
+ m := validPath.FindStringSubmatch(r.URL.Path)
+ if m == nil {
http.NotFound(w, r)
return
}
- fn(w, r, title)
+ fn(w, r, m[2])
}
}