fixes an issue if a request referrer is not available

Squash bug 28

Also closes #803