Skip to content

Commit

Permalink
fix daemonset bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lovehunter9 committed Jul 29, 2024
1 parent 1efcea1 commit cadae2e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/gateway/pkg/proxy/backend_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,23 @@ func rewriteUrl(path string, pvc string, prefix string) string {
klog.Info("secondHalf=", secondHalf)

if strings.HasSuffix(firstHalf, pvc) {
return path
return url.QueryEscape(path)
}
if splitName == "/Home" {
return firstHalf + "/" + pvc + secondHalf
return url.QueryEscape(firstHalf + "/" + pvc + secondHalf)
} else {
secondHalf = strings.TrimPrefix(path[splitIndex:], splitName)
return firstHalf + "/" + pvc + "/Data" + secondHalf
return url.QueryEscape(firstHalf + "/" + pvc + "/Data" + secondHalf)
}
}
} else {
pathSuffix := strings.TrimPrefix(path, prefix)
if strings.HasPrefix(pathSuffix, "/"+pvc) {
return path
return url.QueryEscape(path)
}
return prefix + "/" + pvc + pathSuffix
return url.QueryEscape(prefix + "/" + pvc + pathSuffix)
}
return path
return url.QueryEscape(path)
}

type PVCCache struct {
Expand Down Expand Up @@ -305,6 +305,8 @@ func (p *BackendProxy) Next(c echo.Context) *middleware.ProxyTarget {
src = rewriteUrl(src, userPvc, "")
} else if srcType == "cache" {
src = rewriteUrl(src, cachePvc, API_PASTE_PREFIX+"/AppData")
} else if srcType == "sync" {
src = url.QueryEscape(src)
}

if dstType == "drive" {
Expand All @@ -313,6 +315,8 @@ func (p *BackendProxy) Next(c echo.Context) *middleware.ProxyTarget {
} else if dstType == "cache" {
dst = rewriteUrl(dst, cachePvc, "/AppData")
query.Set("destination", dst)
} else if dstType == "sync" {
dst = url.QueryEscape(dst)
}

newURL := fmt.Sprintf("%s?%s", src, query.Encode())
Expand Down Expand Up @@ -365,7 +369,7 @@ func (p *BackendProxy) Next(c echo.Context) *middleware.ProxyTarget {
klog.Info("new path: ", c.Request().URL.Path)
}

url, _ := url.ParseRequestURI("http://" + host + "/")
url, _ := url.ParseRequestURI(url.QueryEscape("http://" + host + "/"))
klog.Info("Proxy URL: ", url)
return &middleware.ProxyTarget{URL: url}
}
Expand Down

0 comments on commit cadae2e

Please sign in to comment.