Explanation:
You are correct. Whenever you are dealing with equation that have functions in them, you must know their domain restrictions before you simplify.
For instance the function

mUST be defined when x is non negative so that why -1 does not work as a solution. It is a extraneous solution.
Note that however if the function appeared as

x=-1 would be a valid solution. However, we go off the original function for cases like this.