Update UrlGenerator.php

toRoute for better urlencoded paths