Skip to content

Commit d339873

Browse files
committed
refactor(serverHandler): rename alias urlPrefix to aliasPrefix
Alias `urlPrefix` is different from the server's url prefix(--prefix). Rename it to `aliasPrefix`.
1 parent 8aae1c9 commit d339873

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/serverHandler/handler.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type handler struct {
2222
globalHttps bool
2323
httpsPort string // with prefix ":"
2424
defaultSort string
25-
urlPrefix string
25+
aliasPrefix string
2626

2727
dirIndexes []string
2828
aliases aliases
@@ -146,18 +146,18 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
146146
func newHandler(
147147
p *param.Param,
148148
root string,
149-
urlPrefix string,
149+
aliasPrefix string,
150150
allAliases aliases,
151151
users user.List,
152152
theme tpl.Theme,
153153
logger *serverLog.Logger,
154154
errHandler *serverErrHandler.ErrHandler,
155155
) http.Handler {
156-
emptyRoot := p.EmptyRoot && urlPrefix == "/"
156+
emptyRoot := p.EmptyRoot && aliasPrefix == "/"
157157

158158
aliases := aliases{}
159159
for _, alias := range allAliases {
160-
if alias.isSuccessorOf(urlPrefix) {
160+
if alias.isSuccessorOf(aliasPrefix) {
161161
aliases = append(aliases, alias)
162162
}
163163
}
@@ -174,7 +174,7 @@ func newHandler(
174174
globalHttps: p.GlobalHttps,
175175
httpsPort: p.HttpsPort,
176176
defaultSort: p.DefaultSort,
177-
urlPrefix: urlPrefix,
177+
aliasPrefix: aliasPrefix,
178178
aliases: aliases,
179179

180180
dirIndexes: p.DirIndexes,

src/serverHandler/responseData.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func (h *handler) getResponseData(r *http.Request) *responseData {
278278
rawReqPath := r.URL.Path
279279
tailSlash := rawReqPath[len(rawReqPath)-1] == '/'
280280

281-
reqPath := util.CleanUrlPath(rawReqPath[len(h.urlPrefix):]) // strip url prefix path
281+
reqPath := util.CleanUrlPath(rawReqPath[len(h.aliasPrefix):])
282282
reqFsPath, _ := util.NormalizeFsPath(h.root + reqPath)
283283

284284
needAuth := h.getNeedAuth(rawReqPath, reqFsPath)

0 commit comments

Comments
 (0)