File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ package restful
5
5
// that can be found in the LICENSE file.
6
6
7
7
import (
8
+ "fmt"
8
9
"regexp"
9
10
"strconv"
10
11
"strings"
@@ -191,11 +192,15 @@ func (c CrossOriginResourceSharing) isValidAccessControlRequestHeader(header str
191
192
return false
192
193
}
193
194
194
- // Take a list of strings and compile them into a list of regular expressions.
195
- func compileRegexps (regexpStrings []string ) ([]* regexp.Regexp , error ) {
195
+ // Take a list of allowed domains as strings and compile them into a list of regular expressions.
196
+ func compileRegexps (allowedDomains []string ) ([]* regexp.Regexp , error ) {
196
197
regexps := []* regexp.Regexp {}
197
- for _ , regexpStr := range regexpStrings {
198
- r , err := regexp .Compile (regexpStr )
198
+ for _ , each := range allowedDomains {
199
+ // make sure the expression represents an exact match
200
+ if ! strings .HasPrefix (each , "^" ) {
201
+ each = fmt .Sprintf ("^%s$" , each )
202
+ }
203
+ r , err := regexp .Compile (each )
199
204
if err != nil {
200
205
return regexps , err
201
206
}
You can’t perform that action at this time.
0 commit comments