Skip to content

Commit

Permalink
Make path comparison case insensitive
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kytrinyx committed Oct 24, 2014
1 parent 6fb4516 commit 9cbd069
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/iteration.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (iter *Iteration) RelativePath() string {

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

Expand Down
4 changes: 4 additions & 0 deletions api/iteration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func TestIdentify(t *testing.T) {
file: "/Users/me/exercism/bob.rb",
ok: false,
},
{
file: "/users/me/exercism/ruby/bob/bob.rb",
ok: true,
},
{
file: "/Users/me/bob.rb",
ok: false,
Expand Down

0 comments on commit 9cbd069

Please sign in to comment.