prevent index out of range when path is ""