From aebe387f72e2fdaec7d50d171e566dbc281f6128 Mon Sep 17 00:00:00 2001 From: Ning Xie Date: Thu, 13 Jul 2017 09:32:24 +0800 Subject: [PATCH] basicauth: remove magic number (#1760) --- caddyhttp/basicauth/setup.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/caddyhttp/basicauth/setup.go b/caddyhttp/basicauth/setup.go index 0f2c688c..9fa6ddd6 100644 --- a/caddyhttp/basicauth/setup.go +++ b/caddyhttp/basicauth/setup.go @@ -91,8 +91,9 @@ func basicAuthParse(c *caddy.Controller) ([]Rule, error) { } func passwordMatcher(username, passw, siteRoot string) (PasswordMatcher, error) { - if !strings.HasPrefix(passw, "htpasswd=") { + htpasswdPrefix := "htpasswd=" + if !strings.HasPrefix(passw, htpasswdPrefix) { return PlainMatcher(passw), nil } - return GetHtpasswdMatcher(passw[9:], username, siteRoot) + return GetHtpasswdMatcher(passw[len(htpasswdPrefix):], username, siteRoot) }