fix astgen path issues

This commit is contained in:
maddox 2024-09-23 20:00:58 -07:00
parent b2e76ffae0
commit a55bd1a2b4
2 changed files with 4 additions and 4 deletions

View file

@ -292,12 +292,12 @@ func formatRoute(path string) string {
return "/"
}
if !strings.HasPrefix(path, "/") {
path = "/" + path
path = filepath.Join("/", path)
}
if strings.HasSuffix(path, "/") {
return path[:len(path)-1]
return strings.ReplaceAll(path[:len(path)-1], `\`, "/")
}
return path
return strings.ReplaceAll(filepath.Clean(path), `\`, "/")
}
func writePagesFile() {

View file

@ -49,7 +49,7 @@ func WriteFile(path string, cb func(content *ast.File) string) {
slog.Debug("astgen.WriteFile", slog.String("path", path), slog.String("content", string(bytes)))
formatEnabled := false
formatEnabled := true
if formatEnabled {
bytes, err = format.Source(bytes)