Fixed undefined 'pathname' variable