Fix unsafe uses of referrer 'path'

It's not safe to assume all referrer's will have a path. There may be a better way to fix this at a high level (like when we parse the url) but this is the fix I'm currently using to workaround some errors.