Fix pathname escaping problem

Maybe something like this?