saveas: slash-only base name so titles with ':' survive on Windows
This commit is contained in:
parent
13ebc351f5
commit
bd2946b992
1 changed files with 2 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -21,7 +22,7 @@ func saveNameFromTitle(title string, now time.Time) string {
|
||||||
for _, p := range []string{"Microsoft Word - ", "Microsoft Excel - ", "Microsoft PowerPoint - "} {
|
for _, p := range []string{"Microsoft Word - ", "Microsoft Excel - ", "Microsoft PowerPoint - "} {
|
||||||
t = strings.TrimPrefix(t, p)
|
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, " ") {
|
if ext := filepath.Ext(t); ext != "" && len(ext) <= 6 && !strings.ContainsAny(ext, " ") {
|
||||||
t = strings.TrimSuffix(t, ext)
|
t = strings.TrimSuffix(t, ext)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue