Set subdomains to AllowOrigins with wildcard - #1301
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1301 +/- ##
==========================================
+ Coverage 84.21% 84.26% +0.05%
==========================================
Files 26 27 +1
Lines 1951 1989 +38
==========================================
+ Hits 1643 1676 +33
- Misses 202 205 +3
- Partials 106 108 +2
Continue to review full report at Codecov.
|
|
@atsushi-ishibashi I like the idea of supporting subdomains; however, I would like to see a better algorithm which can support nesting as well. Something like below: Split origin & allowed origin by func IsSubDomain(domain, pattern string) bool {
}//cc @im-kulikov @alexaandru |
| allowOrigin = o | ||
| break | ||
| } | ||
| if o != "*" && equalScheme(origin, o) && isSubDomain(origin, o) { |
There was a problem hiding this comment.
- I don't think you need
o != "*" - Make
equalScheme()part of isSubdomain()`
| "strings" | ||
| ) | ||
|
|
||
| func equalScheme(domain, pattern string) bool { |
There was a problem hiding this comment.
I think matchScheme() is a better name
| } | ||
|
|
||
| // isSubDomain compares authority with wildcard | ||
| func isSubDomain(domain, pattern string) bool { |
There was a problem hiding this comment.
Similar to above matchSubdomain() is a better name
close: #1300