saveas: slash-only base name so titles with ':' survive on Windows

This commit is contained in:
Grok Bot (for George) 2026-10-03 20:02:25 -04:00
commit bd2946b992

View file

@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"path"
"path/filepath"
"strings"
"time"
@ -21,7 +22,7 @@ func saveNameFromTitle(title string, now time.Time) string {
for _, p := range []string{"Microsoft Word - ", "Microsoft Excel - ", "Microsoft PowerPoint - "} {
t = strings.TrimPrefix(t, p)
}
t = filepath.Base(strings.ReplaceAll(t, `\`, "/"))
t = path.Base(strings.ReplaceAll(t, `\`, "/")) // slash-only: "a:b" is not a drive here
if ext := filepath.Ext(t); ext != "" && len(ext) <= 6 && !strings.ContainsAny(ext, " ") {
t = strings.TrimSuffix(t, ext)
}