Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace case conversion with equal fold #2870

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions cmd/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ var (
return err
}
if len(args) > 0 {
name := strings.ToLower(args[0])
name := args[0]
for _, t := range templates {
if t.Name == name {
if strings.EqualFold(t.Name, name) {
starter = t
break
}
}
if name != starter.Name {
return errors.New("Invalid template: " + args[0])
if !strings.EqualFold(starter.Name, name) {
return errors.New("Invalid template: " + name)
}
} else {
if err := promptStarterTemplate(ctx, templates); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/sso/internal/saml/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func ValidateMetadataURL(ctx context.Context, metadataURL string) error {
return errors.Errorf("failed to parse metadata uri: %w", err)
}

if strings.ToLower(parsed.Scheme) != "https" {
if !strings.EqualFold(parsed.Scheme, "https") {
return errors.New("only HTTPS Metadata URLs are supported")
}

Expand Down
2 changes: 1 addition & 1 deletion internal/storage/client/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func ParseStorageURL(objectURL string) (string, error) {
if err != nil {
return "", errors.Errorf("failed to parse storage url: %w", err)
}
if strings.ToLower(parsed.Scheme) != STORAGE_SCHEME || len(parsed.Path) == 0 || len(parsed.Host) > 0 {
if !strings.EqualFold(parsed.Scheme, STORAGE_SCHEME) || len(parsed.Path) == 0 || len(parsed.Host) > 0 {
return "", errors.New(ErrInvalidURL)
}
return parsed.Path, nil
Expand Down
6 changes: 3 additions & 3 deletions internal/storage/cp/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func Run(ctx context.Context, src, dst string, recursive bool, maxJobs uint, fsy
if err != nil {
return err
}
if strings.ToLower(srcParsed.Scheme) == client.STORAGE_SCHEME && dstParsed.Scheme == "" {
if strings.EqualFold(srcParsed.Scheme, client.STORAGE_SCHEME) && dstParsed.Scheme == "" {
localPath := dst
if !filepath.IsAbs(dst) {
localPath = filepath.Join(utils.CurrentDirAbs, dst)
Expand All @@ -44,7 +44,7 @@ func Run(ctx context.Context, src, dst string, recursive bool, maxJobs uint, fsy
return DownloadStorageObjectAll(ctx, api, srcParsed.Path, localPath, maxJobs, fsys)
}
return api.DownloadObject(ctx, srcParsed.Path, localPath, fsys)
} else if srcParsed.Scheme == "" && strings.ToLower(dstParsed.Scheme) == client.STORAGE_SCHEME {
} else if srcParsed.Scheme == "" && strings.EqualFold(dstParsed.Scheme, client.STORAGE_SCHEME) {
localPath := src
if !filepath.IsAbs(localPath) {
localPath = filepath.Join(utils.CurrentDirAbs, localPath)
Expand All @@ -53,7 +53,7 @@ func Run(ctx context.Context, src, dst string, recursive bool, maxJobs uint, fsy
return UploadStorageObjectAll(ctx, api, dstParsed.Path, localPath, maxJobs, fsys, opts...)
}
return api.UploadObject(ctx, dstParsed.Path, src, fsys, opts...)
} else if strings.ToLower(srcParsed.Scheme) == client.STORAGE_SCHEME && strings.ToLower(dstParsed.Scheme) == client.STORAGE_SCHEME {
} else if strings.EqualFold(srcParsed.Scheme, client.STORAGE_SCHEME) && strings.EqualFold(dstParsed.Scheme, client.STORAGE_SCHEME) {
return errors.New("Copying between buckets is not supported")
}
utils.CmdSuggestion = fmt.Sprintf("Run %s to copy between local directories.", utils.Aqua("cp -r <src> <dst>"))
Expand Down
4 changes: 2 additions & 2 deletions pkg/parser/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *ReadyState) Next(r rune, data []byte) State {
fallthrough
case 'C':
offset := len(data) - len(BEGIN_ATOMIC)
if offset >= 0 && strings.ToUpper(string(data[offset:])) == BEGIN_ATOMIC {
if offset >= 0 && strings.EqualFold(string(data[offset:]), BEGIN_ATOMIC) {
return &AtomicState{prev: s, delimiter: []byte(END_ATOMIC)}
}
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func (s *AtomicState) Next(r rune, data []byte) State {
if _, ok := s.prev.(*ReadyState); ok {
window := data[len(data)-len(s.delimiter):]
// Treat delimiter as case insensitive
if strings.ToUpper(string(window)) == string(s.delimiter) {
if strings.EqualFold(string(window), string(s.delimiter)) {
return &ReadyState{}
}
}
Expand Down