mirror of
https://github.com/Xpl0itU/WiiUDownloader.git
synced 2025-05-31 07:18:25 -04:00
Fix space as first character in directory name
This commit is contained in:
parent
e40d499b72
commit
18d62273e8
1 changed files with 4 additions and 1 deletions
|
@ -5,6 +5,7 @@ import "strings"
|
||||||
func normalizeFilename(filename string) string {
|
func normalizeFilename(filename string) string {
|
||||||
var out strings.Builder
|
var out strings.Builder
|
||||||
shouldAppend := true
|
shouldAppend := true
|
||||||
|
firstChar := true
|
||||||
|
|
||||||
for _, c := range filename {
|
for _, c := range filename {
|
||||||
switch {
|
switch {
|
||||||
|
@ -13,14 +14,16 @@ func normalizeFilename(filename string) string {
|
||||||
out.WriteRune('_')
|
out.WriteRune('_')
|
||||||
shouldAppend = false
|
shouldAppend = false
|
||||||
}
|
}
|
||||||
|
firstChar = false
|
||||||
case c == ' ':
|
case c == ' ':
|
||||||
if shouldAppend {
|
if shouldAppend && !firstChar {
|
||||||
out.WriteRune(' ')
|
out.WriteRune(' ')
|
||||||
shouldAppend = false
|
shouldAppend = false
|
||||||
}
|
}
|
||||||
case (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'):
|
case (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'):
|
||||||
out.WriteRune(c)
|
out.WriteRune(c)
|
||||||
shouldAppend = true
|
shouldAppend = true
|
||||||
|
firstChar = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue