laravel/framework — pull request #6332 by diogoosorio (2014-11-05 17:48:05+00:00)
Title: Feature/url generator previous without referer

Found this behavior on our application. Whenever there was no referer header, the UrlGenerator::previous() method was returning the project's root URL (which was causing a small bug on our 404 page).

The code wasn't explicit enough for me to understand whether this behavior was intended, or not. I've ended up going directly to the request's HeaderBag instance to probe for the referer header and depending its value conditionally invoking the previous() method - I found no "clean" way to distinguish if the client did arrive from our homepage, or if there was simply no referer.

I've exposed the problem through an unit test. I'd appreciate if someone gave it a look and tell me if this is being done on purpose, or if there's really a problem (I'll address if that's the case).

The culprit source code can be found [here](/laravel/framework/blob/4.2/src/Illuminate/Routing/UrlGenerator.php#L95).