silverstripe/sapphire — pull request #280 by chillu (2012-03-30 16:16:49+00:00)
Title: SS_HTTPRequest normalisation (fixes HTML5 pushState duplication)

When I do a `GET /my/url/` to the SilverStripe routing, it gets rewritten to `/my/url`, removing the trailing slash through the SS_HTTPRequest constructor. This breaks HTML5 pushState support in trunk, as it uses SS_HTTPRequest->getURL() to return a custom HTTP header (X-ControllerURL). The pushState library compares it with the current URL, and re-requests if it doesn't match.

I could patch the library to normalize URLs ignoring trailing slashes, but that just masks the problem in core: We're breaking the concept of canonical URLs, right?

I've fixed this specific instance, but left other modifications in place: Removal of leading slashes (on relative urls), as well as replacement of double slashes with single ones.

The patch could cause some subtle routing bugs,
so keen to get some peer review.

Note: This has been there since we created the SS_HTTPRequest class.