extname is "" not nil, so we should use .empty? to test it.