fix(template): use path.Join and rename param to avoid Windows embed path issue (#1391)

This commit is contained in:
Alireza Gholiei
2025-10-15 17:50:28 -07:00
committed by GitHub
parent 9eb759d567
commit a6e16911cc
+5 -3
View File
@@ -3,6 +3,7 @@ package template
import (
"bufio"
"bytes"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/settings"
templ "github.com/0xJacky/Nginx-UI/template"
@@ -12,8 +13,9 @@ import (
"github.com/tufanbarisyildirim/gonginx/parser"
"github.com/uozi-tech/cosy/logger"
cSettings "github.com/uozi-tech/cosy/settings"
"io"
"path/filepath"
dirPath "path"
"strings"
"text/template"
)
@@ -39,7 +41,7 @@ func GetTemplateInfo(path, name string) (configListItem ConfigInfoItem) {
Filename: name,
}
file, err := templ.DistFS.Open(filepath.Join(path, name))
file, err := templ.DistFS.Open(dirPath.Join(path, name))
if err != nil {
logger.Error(err)
return
@@ -83,7 +85,7 @@ type ConfigDetail struct {
}
func ParseTemplate(path, name string, bindData map[string]Variable) (c ConfigDetail, err error) {
file, err := templ.DistFS.Open(filepath.Join(path, name))
file, err := templ.DistFS.Open(dirPath.Join(path, name))
if err != nil {
err = errors.Wrap(err, "error tokenized template")
return