Fix misidentification of dot in path name

Commit df876d6c7b5 added support for custom default extensions
but it didn't work correctly for directory names containing dots.

Change-Id: I427f694a36496bd8a6f59e3083feb5b8269a62c4