Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>
create: sanitize note name
commands/create.go | 5 +++--
diff --git a/commands/create.go b/commands/create.go index 6917dc19d9c4981e3e22e34f439f0608a3680af8..5139be1acba613ccc54855e7eedfbfd25f33c00c 100644 --- a/commands/create.go +++ b/commands/create.go @@ -6,15 +6,17 @@ "git.sr.ht/~porcellis/t/config" "git.sr.ht/~porcellis/t/models" "os" "path" + "strings" "time" ) -func CreateWithName(config config.TConfig, title string) (models.Note, error) { +func CreateWithName(config config.TConfig, originalTitle string) (models.Note, error) { var ( err error note models.Note ) + title := strings.Replace(originalTitle, " ", "-", -1) file, err := os.Create(path.Join(config.BasePath, fmt.Sprintf("%s.md", title))) stat, _ := file.Stat() @@ -22,7 +24,6 @@ note = models.Note{Name: stat.Name(), Path: path.Join(config.BasePath, stat.Name()), ModTime: stat.ModTime()} return note, err - } func Create(config config.TConfig) (models.Note, error) {