You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #16204 from liggitt/cors-escaping
Automatic merge from submit-queue
Generate escaped regexes for cors config
this ensures the generated config matches hosts exactly instead of treating `.` like a "match any character" rule
// makeHostMatchRegex returns a regex that matches this host exactly.
132
+
// If host contains a port, the returned regex matches the port exactly.
133
+
// If host does not contain a port, the returned regex matches any port or no port.
134
+
funcmakeHostMatchRegex(hoststring) string {
135
+
if_, _, err:=net.SplitHostPort(host); err==nil {
136
+
// we have a port, match the end exactly
137
+
return"//"+regexp.QuoteMeta(host) +"$"
138
+
} else {
139
+
// we don't have a port, match a port separator or the end
140
+
return"//"+regexp.QuoteMeta(host) +"(:|$)"
141
+
}
142
+
}
143
+
130
144
// BuildSerializeableMasterConfig takes the MasterArgs (partially complete config) and uses them along with defaulting behavior to create the fully specified
0 commit comments