Skip to content

Commit 18bdd7f

Browse files
committed
Merge pull request #98 from MichelAraujo/develop
Fixed #91. Changed the position of the function rtrim in me...
2 parents 9e7ee7d + 4130397 commit 18bdd7f

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

library/Respect/Rest/Routes/AbstractRoute.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ public function createUri($param1=null, $etc=null)
159159
$params = func_get_args();
160160
array_unshift($params, $this->regexForReplace);
161161

162-
return rtrim($this->virtualHost, '/') .
162+
$params = preg_replace('#(?<!^)/? *$#', '', $params);
163+
164+
return rtrim($this->virtualHost, ' /') .
163165
call_user_func_array('sprintf', $params);
164166
}
165167

@@ -248,14 +250,17 @@ public function match(Request $request, &$params=array())
248250
*/
249251
protected function createRegexPatterns($pattern)
250252
{
251-
$pattern = rtrim($pattern, ' /');
252-
$extra = $this->extractCatchAllPattern($pattern);
253+
$extra = $this->extractCatchAllPattern($pattern);
254+
253255
$matchPattern = str_replace(
254256
static::QUOTED_PARAM_IDENTIFIER,
255257
static::REGEX_SINGLE_PARAM,
256-
preg_quote($pattern),
258+
preg_quote(rtrim($pattern, ' /')),
257259
$paramCount
258260
);
261+
262+
$pattern = rtrim($pattern);
263+
259264
$replacePattern = str_replace(
260265
static::PARAM_IDENTIFIER,
261266
'/%s',

0 commit comments

Comments
 (0)