Fix: the panic caused by parsing requestinfo slice access out of bounds

Signed-off-by: pingstar <kubeshared.com@gmail.com>
This commit is contained in:
pingstar
2021-03-22 22:29:41 +08:00
parent 6fbaedfaf2
commit 8e2fc3a425

View File

@@ -181,7 +181,7 @@ func (r *RequestInfoFactory) NewRequestInfo(req *http.Request) (*RequestInfo, er
requestInfo.APIVersion = currentParts[0]
currentParts = currentParts[1:]
if specialVerbs.Has(currentParts[0]) {
if len(currentParts) > 0 && specialVerbs.Has(currentParts[0]) {
if len(currentParts) < 2 {
return &requestInfo, fmt.Errorf("unable to determine kind and namespace from url: %v", req.URL)
}