Skip to content

Commit e012733

Browse files
committed
chore: trim spaces from the CORS configuration values
Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
1 parent 7fb0b88 commit e012733

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

plugin.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,26 @@ func (p *Plugin) Init(cfg Configurer) error {
6565
}
6666

6767
if p.cfg.CORS.AllowedOrigin != "" {
68+
// trim all spaces
69+
p.cfg.CORS.AllowedOrigin = strings.Trim(p.cfg.CORS.AllowedOrigin, " ")
6870
opts.AllowedOrigins = strings.Split(p.cfg.CORS.AllowedOrigin, ",")
6971
}
7072

7173
if p.cfg.CORS.AllowedMethods != "" {
74+
// trim all spaces
75+
p.cfg.CORS.AllowedMethods = strings.Trim(p.cfg.CORS.AllowedMethods, " ")
7276
opts.AllowedMethods = strings.Split(p.cfg.CORS.AllowedMethods, ",")
7377
}
7478

7579
if p.cfg.CORS.AllowedHeaders != "" {
80+
// trim all spaces
81+
p.cfg.CORS.AllowedHeaders = strings.Trim(p.cfg.CORS.AllowedHeaders, " ")
7682
opts.AllowedHeaders = strings.Split(p.cfg.CORS.AllowedHeaders, ",")
7783
}
7884

7985
if p.cfg.CORS.ExposedHeaders != "" {
86+
// trim all spaces
87+
p.cfg.CORS.ExposedHeaders = strings.Trim(p.cfg.CORS.ExposedHeaders, " ")
8088
opts.ExposedHeaders = strings.Split(p.cfg.CORS.ExposedHeaders, ",")
8189
}
8290

0 commit comments

Comments
 (0)