mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-07-04 17:06:49 +00:00
Add backend unit tests
This commit is contained in:
@ -25,14 +25,21 @@ func NotFound() func(http.ResponseWriter, *http.Request) {
|
||||
assetsSub, _ = fs.Sub(embed.Assets, "assets")
|
||||
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
defaultFile := "index.html"
|
||||
path := strings.TrimLeft(r.URL.Path, "/")
|
||||
|
||||
isAPI := false
|
||||
if len(path) >= 3 && path[0:3] == "api" {
|
||||
isAPI = true
|
||||
}
|
||||
|
||||
if path == "" {
|
||||
path = "index.html"
|
||||
path = defaultFile
|
||||
}
|
||||
|
||||
err := tryRead(assetsSub, path, w)
|
||||
if err == errIsDir {
|
||||
err = tryRead(assetsSub, "index.html", w)
|
||||
err = tryRead(assetsSub, defaultFile, w)
|
||||
if err != nil {
|
||||
h.NotFound(w, r)
|
||||
}
|
||||
@ -40,6 +47,16 @@ func NotFound() func(http.ResponseWriter, *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Check if the path has an extension and not in the "/api" path
|
||||
ext := filepath.Ext(path)
|
||||
if !isAPI && ext == "" {
|
||||
// Not an api endpoint and Not a specific file, return the default index file
|
||||
err := tryRead(assetsSub, defaultFile, w)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
h.NotFound(w, r)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user