Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
75ce8796
Commit
75ce8796
authored
Oct 30, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
got rid of URI class and brought URI determination back to into request class.
parent
ef9e4dfd
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
107 deletions
+32
-107
form.php
laravel/form.php
+1
-1
laravel.php
laravel/laravel.php
+1
-2
paginator.php
laravel/paginator.php
+1
-1
request.php
laravel/request.php
+28
-4
uri.php
laravel/uri.php
+0
-98
RequestTest.php
tests/Cases/RequestTest.php
+1
-1
No files found.
laravel/form.php
View file @
75ce8796
...
@@ -82,7 +82,7 @@ class Form {
...
@@ -82,7 +82,7 @@ class Form {
*/
*/
protected
static
function
action
(
$action
,
$https
)
protected
static
function
action
(
$action
,
$https
)
{
{
return
HTML
::
entities
(
URL
::
to
(((
is_null
(
$action
))
?
Request
::
uri
()
->
get
()
:
$action
),
$https
));
return
HTML
::
entities
(
URL
::
to
(((
is_null
(
$action
))
?
Request
::
uri
()
:
$action
),
$https
));
}
}
/**
/**
...
...
laravel/laravel.php
View file @
75ce8796
...
@@ -37,7 +37,6 @@ if (Config::$items['session']['driver'] !== '')
...
@@ -37,7 +37,6 @@ if (Config::$items['session']['driver'] !== '')
* Manually load some core classes that are used on every request
* Manually load some core classes that are used on every request
* This allows to avoid using the loader for these classes.
* This allows to avoid using the loader for these classes.
*/
*/
require
SYS_PATH
.
'uri'
.
EXT
;
require
SYS_PATH
.
'input'
.
EXT
;
require
SYS_PATH
.
'input'
.
EXT
;
require
SYS_PATH
.
'request'
.
EXT
;
require
SYS_PATH
.
'request'
.
EXT
;
require
SYS_PATH
.
'response'
.
EXT
;
require
SYS_PATH
.
'response'
.
EXT
;
...
@@ -91,7 +90,7 @@ Input::$input = $input;
...
@@ -91,7 +90,7 @@ Input::$input = $input;
*/
*/
Routing\Filter
::
register
(
require
APP_PATH
.
'filters'
.
EXT
);
Routing\Filter
::
register
(
require
APP_PATH
.
'filters'
.
EXT
);
list
(
$uri
,
$method
)
=
array
(
Request
::
uri
()
->
get
()
,
Request
::
method
());
list
(
$uri
,
$method
)
=
array
(
Request
::
uri
(),
Request
::
method
());
Request
::
$route
=
IoC
::
container
()
->
core
(
'routing.router'
)
->
route
(
$method
,
$uri
);
Request
::
$route
=
IoC
::
container
()
->
core
(
'routing.router'
)
->
route
(
$method
,
$uri
);
...
...
laravel/paginator.php
View file @
75ce8796
...
@@ -250,7 +250,7 @@ class Paginator {
...
@@ -250,7 +250,7 @@ class Paginator {
// We will assume the page links should use HTTPS if the current request
// We will assume the page links should use HTTPS if the current request
// is also using HTTPS. Since pagination links automatically point to
// is also using HTTPS. Since pagination links automatically point to
// the current URI, this makes pretty good sense.
// the current URI, this makes pretty good sense.
list
(
$uri
,
$secure
)
=
array
(
Request
::
uri
()
->
get
()
,
Request
::
secure
());
list
(
$uri
,
$secure
)
=
array
(
Request
::
uri
(),
Request
::
secure
());
$appendage
=
$this
->
appendage
(
$element
,
$page
);
$appendage
=
$this
->
appendage
(
$element
,
$page
);
...
...
laravel/request.php
View file @
75ce8796
...
@@ -5,7 +5,7 @@ class Request {
...
@@ -5,7 +5,7 @@ class Request {
/**
/**
* The request URI for the current request.
* The request URI for the current request.
*
*
* @var
URI
* @var
string
*/
*/
public
static
$uri
;
public
static
$uri
;
...
@@ -24,13 +24,37 @@ class Request {
...
@@ -24,13 +24,37 @@ class Request {
const
spoofer
=
'__spoofer'
;
const
spoofer
=
'__spoofer'
;
/**
/**
* Get the
URI instance for the current request
.
* Get the
current request's URI
.
*
*
* @return
URI
* @return
string
*/
*/
public
static
function
uri
()
public
static
function
uri
()
{
{
return
(
is_null
(
static
::
$uri
))
?
static
::
$uri
=
new
URI
(
$_SERVER
)
:
static
::
$uri
;
if
(
!
is_null
(
static
::
$uri
))
return
static
::
$uri
;
$uri
=
$_SERVER
[
'REQUEST_URI'
];
// Remove the root application URL from the request URI. If the application
// is nested within a sub-directory of the web document root, this will get
// rid of the sub-directories from the request URI.
$base
=
parse_url
(
Config
::
$items
[
'application'
][
'url'
],
PHP_URL_PATH
);
if
(
strpos
(
$uri
,
$base
)
===
0
)
{
$uri
=
substr
(
$uri
,
strlen
(
$base
));
}
$index
=
'/'
.
Config
::
$items
[
'application'
][
'index'
];
if
(
$index
!==
'/'
and
strpos
(
$uri
,
$index
)
===
0
)
{
$uri
=
substr
(
$uri
,
strlen
(
$index
));
}
// If all we are left with is an empty string, we will return a single forward
// slash indicating the request is to the root of the application. If we have
// something left, we will its remove the leading and trailing slashes.
return
static
::
$uri
=
((
$uri
=
trim
(
$uri
,
'/'
))
!==
''
)
?
$uri
:
'/'
;
}
}
/**
/**
...
...
laravel/uri.php
deleted
100644 → 0
View file @
ef9e4dfd
<?php
namespace
Laravel
;
class
URI
{
/**
* The request URI for the current request.
*
* @var string
*/
protected
$uri
;
/**
* The $_SERVER global array for the current request.
*
* @var array
*/
protected
$server
;
/**
* Create a new instance of the URI class.
*
* @param array $server
* @return void
*/
public
function
__construct
(
$server
)
{
$this
->
server
=
$server
;
}
/**
* Get the request URI for the current request.
*
* If the request is to the root of the application, a single forward slash
* will be returned. Otherwise, the URI will be returned with all leading
* and trailing slashes removed. The application URL and index file will
* also be removed since they are not used when routing the request.
*
* @return string
*/
public
function
get
()
{
if
(
!
is_null
(
$this
->
uri
))
return
$this
->
uri
;
return
$this
->
uri
=
$this
->
format
(
$this
->
clean
(
$this
->
parse
(
$this
->
server
[
'REQUEST_URI'
])));
}
/**
* Remove extraneous information from the given request URI.
*
* @param string $uri
* @return string
*/
protected
function
clean
(
$uri
)
{
$uri
=
$this
->
remove
(
$uri
,
$this
->
parse
(
Config
::
$items
[
'application'
][
'url'
]));
if
((
$index
=
'/'
.
Config
::
$items
[
'application'
][
'index'
])
!==
'/'
)
{
$uri
=
$this
->
remove
(
$uri
,
$index
);
}
return
$uri
;
}
/**
* Parse a given string URI using PHP_URL_PATH to remove the domain.
*
* @return string
*/
protected
function
parse
(
$uri
)
{
return
parse_url
(
$uri
,
PHP_URL_PATH
);
}
/**
* Remove a string from the beginning of a URI.
*
* @param string $uri
* @param string $remove
* @return string
*/
protected
function
remove
(
$uri
,
$remove
)
{
return
(
strpos
(
$uri
,
$remove
)
===
0
)
?
substr
(
$uri
,
strlen
(
$remove
))
:
$uri
;
}
/**
* Format the URI for use throughout the framework.
*
* @param string $uri
* @return string
*/
protected
function
format
(
$uri
)
{
return
((
$uri
=
trim
(
$uri
,
'/'
))
!==
''
)
?
$uri
:
'/'
;
}
}
\ No newline at end of file
tests/Cases/RequestTest.php
View file @
75ce8796
...
@@ -16,7 +16,7 @@ class RequestTest extends PHPUnit_Framework_TestCase {
...
@@ -16,7 +16,7 @@ class RequestTest extends PHPUnit_Framework_TestCase {
public
function
test_correct_uri_is_returned_when_request_uri_is_used
(
$uri
,
$expectation
)
public
function
test_correct_uri_is_returned_when_request_uri_is_used
(
$uri
,
$expectation
)
{
{
$_SERVER
[
'REQUEST_URI'
]
=
$uri
;
$_SERVER
[
'REQUEST_URI'
]
=
$uri
;
$this
->
assertEquals
(
$expectation
,
Laravel\Request
::
uri
()
->
get
()
);
$this
->
assertEquals
(
$expectation
,
Laravel\Request
::
uri
());
}
}
public
function
test_request_method_returns_spoofed_method_if_uri_is_spoofed
()
public
function
test_request_method_returns_spoofed_method_if_uri_is_spoofed
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment