Fixes #7164: Cannot create a domain that starts or ends with '.'

instead of going the entire string and revesing it, you could consider using str[0] and str[-1] (first and last)?