Cannot read property 'pathname' of null