Do not remove last path segment unless hash or query are present.