Browse Source

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

Alireza Gholiei 5 days ago
parent
commit
a6e16911cc
1 changed files with 5 additions and 3 deletions
  1. 5 3
      internal/template/template.go

+ 5 - 3
internal/template/template.go

@@ -3,6 +3,7 @@ package template
 import (
 import (
 	"bufio"
 	"bufio"
 	"bytes"
 	"bytes"
+
 	"github.com/0xJacky/Nginx-UI/internal/nginx"
 	"github.com/0xJacky/Nginx-UI/internal/nginx"
 	"github.com/0xJacky/Nginx-UI/settings"
 	"github.com/0xJacky/Nginx-UI/settings"
 	templ "github.com/0xJacky/Nginx-UI/template"
 	templ "github.com/0xJacky/Nginx-UI/template"
@@ -12,8 +13,9 @@ import (
 	"github.com/tufanbarisyildirim/gonginx/parser"
 	"github.com/tufanbarisyildirim/gonginx/parser"
 	"github.com/uozi-tech/cosy/logger"
 	"github.com/uozi-tech/cosy/logger"
 	cSettings "github.com/uozi-tech/cosy/settings"
 	cSettings "github.com/uozi-tech/cosy/settings"
+
 	"io"
 	"io"
-	"path/filepath"
+	dirPath "path"
 	"strings"
 	"strings"
 	"text/template"
 	"text/template"
 )
 )
@@ -39,7 +41,7 @@ func GetTemplateInfo(path, name string) (configListItem ConfigInfoItem) {
 		Filename:    name,
 		Filename:    name,
 	}
 	}
 
 
-	file, err := templ.DistFS.Open(filepath.Join(path, name))
+	file, err := templ.DistFS.Open(dirPath.Join(path, name))
 	if err != nil {
 	if err != nil {
 		logger.Error(err)
 		logger.Error(err)
 		return
 		return
@@ -83,7 +85,7 @@ type ConfigDetail struct {
 }
 }
 
 
 func ParseTemplate(path, name string, bindData map[string]Variable) (c ConfigDetail, err error) {
 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 {
 	if err != nil {
 		err = errors.Wrap(err, "error tokenized template")
 		err = errors.Wrap(err, "error tokenized template")
 		return
 		return