Skip to content

Commit 524f826

Browse files
committed
1 parent 46be28a commit 524f826

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

FSNotes/View/TitleTextField.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,19 @@ class TitleTextField: NSTextField {
6767

6868
let currentName = note.getFileName()
6969
let ext = note.url.pathExtension
70-
let dst = note.project.url.appendingPathComponent(currentTitle).appendingPathExtension(ext)
70+
let fileName =
71+
currentTitle
72+
.trimmingCharacters(in: CharacterSet.whitespaces)
73+
.replacingOccurrences(of: ":", with: "-")
74+
.replacingOccurrences(of: "/", with: ":")
75+
76+
let dst = note.project.url
77+
.appendingPathComponent(fileName)
78+
.appendingPathExtension(ext)
7179

7280
if !FileManager.default.fileExists(atPath: dst.path), note.move(to: dst) {
73-
vc.updateTitle(newTitle: currentTitle)
81+
let newTitle = currentTitle.replacingOccurrences(of: ":", with: "-")
82+
vc.updateTitle(newTitle: newTitle)
7483

7584
updateNotesTableView()
7685
} else {

0 commit comments

Comments
 (0)