1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
	/**
	 * Custom handle request to ensure that a trailing slash is always added.
	 * 
	 * @return SS_HTTPResponse
	 */
	function handleRequest(SS_HTTPRequest $request) {
		if($request && $request->isGET()) {
			$url = $request->getVar('url');
			
			// check for trailing slash.
			if(strlen($url) > 1 && substr($url, -1, 1) != "/") {
				$response = new SS_HTTPResponse();
				$params = $request->getVars();
				if(isset($params['url'])) unset($params['url']);
				$response->redirect(
					Controller::join_links(
						$url,
						'/',
						($params) ? '?' . http_build_query($params) : null
					),
					301
				);
				
				return $response;
			}
		}
		
		return parent::handleRequest($request);
	}