Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions internal/tspath/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,40 @@ func GetCanonicalFileName(fileName string, useCaseSensitiveFileNames bool) strin
// Rest special characters are either already in lower case format or
// they have corresponding upper case character so they dont need special handling

func ToFileNameLowerCase(fileName string) string {
func ToFileNameLowerCase(s string) string {
const IWithDot = '\u0130'

ascii := true
needsLower := false
for _, c := range []byte(s) {
if c >= 0x80 {
ascii = false
break
}
if 'A' <= c && c <= 'Z' {
needsLower = true
}
}
if ascii {
if !needsLower {
return s
}
b := make([]byte, len(s))
for i, c := range []byte(s) {
if 'A' <= c && c <= 'Z' {
c += 'a' - 'A' // +32
}
b[i] = c
}
return string(b)
}

return strings.Map(func(r rune) rune {
if r == '\u0130' {
if r == IWithDot {
return r
}
return unicode.ToLower(r)
}, fileName)
}, s)
}

func ToPath(fileName string, basePath string, useCaseSensitiveFileNames bool) Path {
Expand Down
Loading