While trying to get hold of the development of elliptic integrals $K(k), E(k) $ for $k=\sin(\pi/12)=(\sqrt{3}-1)/2\sqrt{2}$ by Legendre, I read some parts of Legendre's Exercises de Calcul Integral (in French, available at archive.org). In particular on page 56, article 39, example 1 he starts with integral $$M=\int_0^1\frac{z^{-2/3}\,dz}{\sqrt{1-z^2}}\tag{1}$$ The integral can be evaluated easily using Beta and Gamma functions and that is not the concern here.
Legendre makes the substitution $z=(1-x^2)^{-3/2}$ and says that it leads to $$M=\int_0^{\infty}\frac{3\,dx}{\sqrt{3+3x^2+x^4}}\tag{2}$$ and then he goes on to relate the above integral to elliptic integrals $K(k), E(k) $. Performing the substitution does lead to the desired integrand, but the issue is that the substitution $z=(1-x^2)^{-3/2}$ leads to imaginary values of $z$ when $x>1$ and hence the limits $0,\infty$ for $x$ don't appear to make sense.
I think there is a way to salvage this and probably Legendre omitted some steps here. So how can we transform the integral $(1)$ into integral $(2)$ perhaps by using some other substitution or by doing some adjustments to the approach used by Legendre?
Note: My understanding of French is zero so I am just looking at the math in Legendre's text and trying to make sense of it.
As the accepted answer shows the issue is caused by a typo in Legendre's text. I was performing the substitution in my mind while reading the text. Had I been using a bit of pen and paper I would have noticed sign errors in integrand after making the substitution.