Skip to content

Commit eeb5ac9

Browse files
committed
fix logic when .br is absent
1 parent 3fc83c9 commit eeb5ac9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

modules/public/public.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,19 @@ func (opts *Options) handle(ctx *macaron.Context, log *log.Logger, opt *Options)
119119
var err error
120120
if encodings["br"] {
121121
f, err = opt.FileSystem.Open(file + ".br")
122-
if err != nil {
123-
f, err = opt.FileSystem.Open(file)
124-
} else {
122+
if f != nil {
125123
ctx.Resp.Header().Set("Content-Encoding", "br")
126124
}
127-
} else if encodings["gzip"] {
125+
}
126+
127+
if f == nil && encodings["gzip"] {
128128
f, err = opt.FileSystem.Open(file + ".gz")
129-
if err != nil {
130-
f, err = opt.FileSystem.Open(file)
131-
} else {
129+
if f != nil {
132130
ctx.Resp.Header().Set("Content-Encoding", "gzip")
133131
}
134-
} else {
132+
}
133+
134+
if f == nil {
135135
f, err = opt.FileSystem.Open(file)
136136
}
137137

0 commit comments

Comments
 (0)