Skip to content

Commit a6e1691

Browse files
fix(template): use path.Join and rename param to avoid Windows embed path issue (#1391)
1 parent 9eb759d commit a6e1691

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal/template/template.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package template
33
import (
44
"bufio"
55
"bytes"
6+
67
"github.com/0xJacky/Nginx-UI/internal/nginx"
78
"github.com/0xJacky/Nginx-UI/settings"
89
templ "github.com/0xJacky/Nginx-UI/template"
@@ -12,8 +13,9 @@ import (
1213
"github.com/tufanbarisyildirim/gonginx/parser"
1314
"github.com/uozi-tech/cosy/logger"
1415
cSettings "github.com/uozi-tech/cosy/settings"
16+
1517
"io"
16-
"path/filepath"
18+
dirPath "path"
1719
"strings"
1820
"text/template"
1921
)
@@ -39,7 +41,7 @@ func GetTemplateInfo(path, name string) (configListItem ConfigInfoItem) {
3941
Filename: name,
4042
}
4143

42-
file, err := templ.DistFS.Open(filepath.Join(path, name))
44+
file, err := templ.DistFS.Open(dirPath.Join(path, name))
4345
if err != nil {
4446
logger.Error(err)
4547
return
@@ -83,7 +85,7 @@ type ConfigDetail struct {
8385
}
8486

8587
func ParseTemplate(path, name string, bindData map[string]Variable) (c ConfigDetail, err error) {
86-
file, err := templ.DistFS.Open(filepath.Join(path, name))
88+
file, err := templ.DistFS.Open(dirPath.Join(path, name))
8789
if err != nil {
8890
err = errors.Wrap(err, "error tokenized template")
8991
return

0 commit comments

Comments
 (0)