[fix] the spa router length bug

This commit is contained in:
Max 2023-09-07 22:40:11 +08:00
parent 68ebf1e6cc
commit 955920e868

View file

@ -39,8 +39,8 @@ func withStaticFileServer(c *gin.Context) {
} }
// PWA app static file server // PWA app static file server
for root, length := range SpaRoots { for root, rootLength := range SpaRoots {
if length >= length && c.Request.URL.Path[0:length] == root { if rootLength >= length && c.Request.URL.Path[0:length] == root {
c.Request.URL.Path = strings.TrimPrefix(c.Request.URL.Path, root) c.Request.URL.Path = strings.TrimPrefix(c.Request.URL.Path, root)
spaFileServers[root].ServeHTTP(c.Writer, c.Request) spaFileServers[root].ServeHTTP(c.Writer, c.Request)
c.Abort() c.Abort()