Skip to content

Commit

Permalink
Filter /index from url
Browse files Browse the repository at this point in the history
  • Loading branch information
tbreuss committed Feb 11, 2014
1 parent 140acbd commit 2eac330
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/Herbie/Url/UrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ public function __construct(Request $request, $niceUrls)
public function generate($route)
{
if ($this->niceUrls) {
return $this->request->getBaseUrl() . '/' . $route;
$url = $this->request->getBaseUrl() . '/' . $route;
} else {
return $this->request->getScriptName() . '/' . $route;
$url = $this->request->getScriptName() . '/' . $route;
}
return $this->filterUrl($url);
}

/**
Expand All @@ -62,4 +63,17 @@ public function generateAbsolute($route)
return $baseurl . $this->generate($route);
}

/**
* @param string $url
* @return string
*/
protected function filterUrl($url)
{
$rpos = strrpos($url, '/index');
if($rpos !== false) {
$url = substr($url, 0, $rpos);
}
return $url;
}

}

0 comments on commit 2eac330

Please sign in to comment.