mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-06-19 07:36:59 +00:00
fix(template): use path.Join and rename param to avoid Windows embed path issue (#1391)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user