Permalink
Browse files

renamed enableStrictRouting, allow for multiple trailing slashes by d…

…efault, added * param
  • Loading branch information...
1 parent 28c27b6 commit 02590de29ea3cb71143c4e7590624041da5b995e @jeffturcotte jeffturcotte committed Jan 30, 2012
Showing with 10 additions and 18 deletions.
  1. +8 −16 Anchor.php
  2. +2 −2 README
View
@@ -10,7 +10,9 @@
* @package Anchor
* @link http://github.com/jeffturcotte/anchor
*
- * @version 1.0.0a6
+ * @version 1.0.0a8
+ * @changes 1.0.0a8 Renamed enableStrictRouting to disableTrailingSlashRedirect [jt, 2012-01-30]
+ * @changes 1.0.0a7 Added * param type to replace * prefix and suffix [jt, 2012-01-30]
* @changes 1.0.0a6 Added support for different URL formatters for different params [wb, 2011-10-18]
* @changes 1.0.0a5 Added check() [wb, 2011-09-22]
* @changes 1.0.0a4 Added setCallbackParamName() [jt, 2011-09-08]
@@ -272,7 +274,8 @@ function notFound()
':' => '[^/]+',
'!' => '[A-Za-z][A-Za-z0-9_]+',
'^' => '[0-9]+',
- '@' => '[A-Za-z]+'
+ '@' => '[A-Za-z]+',
+ '*' => '.+'
);
private static $templates = array();
@@ -344,15 +347,12 @@ function notFound()
* - !param will match any valid PHP identifier name, i.e. letters, numbers and underscore
* - ^param will match digits
* - @param will match letters
+ * - *param will match anything (greedy)
*
* The following $map will match numeric user IDs:
*
* /users/view/%id/preferences
*
- * A * will match any character, but is only valid at the end of a $map:
- *
- * /resources/%id/*
- *
* A $map can also match specific HTTP headers by using the [header=value]
* syntax before a path name. A space must be present between the closing ]
* and the beginning of the path.
@@ -545,7 +545,7 @@ public static function clear()
*
* @return void
*/
- public static function enableStrictRouting()
+ public static function disableTrailingSlashRedirect()
{
self::$redirect_trailing_slashes = FALSE;
}
@@ -1850,15 +1850,7 @@ private static function parseUrl($url)
);
}
- $url->pattern = (substr($url->pattern, 0, 1) != '*')
- ? '^' . $url->pattern
- : substr($url->pattern, 1);
-
- $url->pattern = (substr($url->pattern, -1) != '*')
- ? $url->pattern . '$'
- : substr($url->pattern, 0, strlen($url->pattern) - 1);
-
- $url->pattern = '`' . $url->pattern . '`';
+ $url->pattern = '`^' . $url->pattern . '/*?$`';
$url->param_aliases = array();
View
4 README
@@ -46,6 +46,7 @@ a request variable name. The four symbols are the following single character:
: - matches anything but a slash
% - matches numbers
@ - matches letters
+* - matches anything
Here is an example of pulling a numeric id and string slug out of a URL:
@@ -112,12 +113,11 @@ Anchor::add('404', 'Home::notFound');
Anchor::run();
-
// Controller class in /path/to/controller/dir/Users.php
class Users {
public function view($data) {
$id = $_GET['id'];
// do stuff here and output response
}
-}
+}

0 comments on commit 02590de

Please sign in to comment.