move 'is' method to the str class where it belongs.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php namespace Laravel\Routing;
|
||||
|
||||
use Closure;
|
||||
use Laravel\Str;
|
||||
use Laravel\URI;
|
||||
use Laravel\Bundle;
|
||||
use Laravel\Request;
|
||||
@@ -198,7 +199,7 @@ class Route {
|
||||
// if they match we'll attach the filter.
|
||||
foreach (Filter::$patterns as $pattern => $filter)
|
||||
{
|
||||
if (URI::is($pattern, $this->uri))
|
||||
if (Str::is($pattern, $this->uri))
|
||||
{
|
||||
$filters[] = $filter;
|
||||
}
|
||||
|
||||
@@ -300,6 +300,30 @@ class Str {
|
||||
return substr(str_shuffle(str_repeat(static::pool($type), 5)), 0, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a given string matches a given pattern.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function is($pattern, $value)
|
||||
{
|
||||
// Asterisks are translated into zero-or-more regular expression wildcards
|
||||
// to make it convenient to check if the URI starts with a given pattern
|
||||
// such as "library/*". This is only done when not root.
|
||||
if ($pattern !== '/')
|
||||
{
|
||||
$pattern = str_replace('*', '(.*)', $pattern).'\z';
|
||||
}
|
||||
else
|
||||
{
|
||||
$pattern = '^/$';
|
||||
}
|
||||
|
||||
return preg_match('#'.$pattern.'#', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the character pool for a given type of random string.
|
||||
*
|
||||
|
||||
@@ -60,26 +60,11 @@ class URI {
|
||||
* Determine if the current URI matches a given pattern.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $uri
|
||||
* @return bool
|
||||
*/
|
||||
public static function is($pattern, $uri = null)
|
||||
public static function is($pattern)
|
||||
{
|
||||
$uri = $uri ?: static::current();
|
||||
|
||||
// Asterisks are translated into zero-or-more regular expression wildcards
|
||||
// to make it convenient to check if the URI starts with a given pattern
|
||||
// such as "library/*". This is only done when not root.
|
||||
if ($pattern !== '/')
|
||||
{
|
||||
$pattern = str_replace('*', '(.*)', $pattern).'\z';
|
||||
}
|
||||
else
|
||||
{
|
||||
$pattern = '^/$';
|
||||
}
|
||||
|
||||
return preg_match('#'.$pattern.'#', $uri);
|
||||
return Str::is($pattern, static::current());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
19
paths.php
19
paths.php
@@ -8,6 +8,25 @@
|
||||
* @link http://laravel.com
|
||||
*/
|
||||
|
||||
/*
|
||||
|----------------------------------------------------------------
|
||||
| Application Environemtns
|
||||
|----------------------------------------------------------------
|
||||
|
|
||||
| Laravel takes a dead simple approach to environments, and we
|
||||
| think you'll love it. Just specify which URLs belongs to a
|
||||
| given environment, and when you access your application
|
||||
| from a URL matching that pattern, we'll be sure to
|
||||
| merge in that environment's configuration files.
|
||||
|
|
||||
*/
|
||||
|
||||
$environments = array(
|
||||
|
||||
'local' => array('*localhost*', '*.dev'),
|
||||
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// The path to the application directory.
|
||||
// --------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user