Skip to content

Commit 9cbd069

Browse files
committed
Make path comparison case insensitive
On one mac os x system, the directory is reported as /Users/username/exercism in one place and /users/username/exercism in another. Since both mac and windows are case insensitive in terms of creating directories on a system (cannot have Hello and hello in the same location), lowercasing both the filename and the directory before comparing them seems like a fairly innocuous approach.
1 parent 6fb4516 commit 9cbd069

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

api/iteration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (iter *Iteration) RelativePath() string {
3737

3838
// Identify attempts to determine the track and problem of an iteration.
3939
func (iter *Iteration) Identify() error {
40-
if !strings.HasPrefix(iter.File, iter.Dir) {
40+
if !strings.HasPrefix(strings.ToLower(iter.File), strings.ToLower(iter.Dir)) {
4141
return fmt.Errorf(msgUnidentifiable)
4242
}
4343

api/iteration_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ func TestIdentify(t *testing.T) {
1919
file: "/Users/me/exercism/bob.rb",
2020
ok: false,
2121
},
22+
{
23+
file: "/users/me/exercism/ruby/bob/bob.rb",
24+
ok: true,
25+
},
2226
{
2327
file: "/Users/me/bob.rb",
2428
ok: false,

0 commit comments

Comments
 (0)