mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Normalize filenames when writing
This commit is contained in:
parent
f2b317be8b
commit
a3d1b822e4
5
page.go
5
page.go
@ -23,12 +23,11 @@ type Page struct {
|
||||
}
|
||||
|
||||
func Open(name string) (p *Page) {
|
||||
name = strings.ToLower(name) // no case
|
||||
p = new(Page)
|
||||
p.Name = name
|
||||
p.Text = versionedtext.NewVersionedText("")
|
||||
p.Render()
|
||||
bJSON, err := ioutil.ReadFile(path.Join(pathToData, encodeToBase32(name)+".json"))
|
||||
bJSON, err := ioutil.ReadFile(path.Join(pathToData, encodeToBase32(strings.ToLower(name))+".json"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -66,7 +65,7 @@ func (p *Page) Save() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(path.Join(pathToData, encodeToBase32(p.Name)+".json"), bJSON, 0755)
|
||||
return ioutil.WriteFile(path.Join(pathToData, encodeToBase32(strings.ToLower(p.Name))+".json"), bJSON, 0755)
|
||||
}
|
||||
|
||||
func (p *Page) Erase() error {
|
||||
|
Loading…
Reference in New Issue
Block a user