Fix issue when getting the domain of a directory

In some cases directories are registered with a postfix directory
separator, so we now check this possibility.