Skip to content

Commit

Permalink
Fix wiki name directory issue while performing create action (#103)
Browse files Browse the repository at this point in the history
* Fix wiki name directory issue while performing create action

* Fix wiki name issue

* Fix wiki name issue
  • Loading branch information
naresh-kumar-babu authored Aug 13, 2024
1 parent 13b43d8 commit fc95611
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/canasta/canasta.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"strings"
"regexp"

"github.com/CanastaWiki/Canasta-CLI-Go/internal/config"
"github.com/CanastaWiki/Canasta-CLI-Go/internal/execute"
Expand Down Expand Up @@ -90,7 +91,10 @@ func CopySettings(path string) error {
return err
}
for i := len(WikiNames) - 1; i >= 0; i-- {
dirPath := path + fmt.Sprintf("/config/%s", WikiNames[i])
// Replace spaces to underlines and remove accented and non-alphanumeric characters
name := strings.Replace(WikiNames[i], " ", "_", -1)
name = regexp.MustCompile("[^a-zA-Z0-9_]+").ReplaceAllString(name,"")
dirPath := path + fmt.Sprintf("/config/%s", name)

// Create the directory if it doesn't exist
if err := os.MkdirAll(dirPath, os.ModePerm); err != nil {
Expand Down

0 comments on commit fc95611

Please sign in to comment.