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
3c216d89
Commit
3c216d89
authored
Jul 25, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring URL class.
parent
6e9bf0a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
15 deletions
+9
-15
url.php
system/url.php
+9
-15
No files found.
system/url.php
View file @
3c216d89
...
@@ -5,33 +5,27 @@ class URL {
...
@@ -5,33 +5,27 @@ class URL {
/**
/**
* Generate an application URL.
* Generate an application URL.
*
*
* If the given URL is already well-formed, it will be returned unchanged.
*
* @param string $url
* @param string $url
* @param bool $https
* @param bool $https
* @param bool $asset
* @return string
* @return string
*/
*/
public
static
function
to
(
$url
=
''
,
$https
=
false
,
$asset
=
false
)
public
static
function
to
(
$url
=
''
,
$https
=
false
)
{
{
if
(
strpos
(
$url
,
'://'
)
!==
false
)
if
(
filter_var
(
$url
,
FILTER_VALIDATE_URL
)
!==
false
)
{
{
return
$url
;
return
$url
;
}
}
$base
=
Config
::
get
(
'application.url'
);
$base
=
Config
::
get
(
'application.url'
)
.
'/'
.
Config
::
get
(
'application.index'
);
// If the URL is being generated for a public asset such as an
// image, we do not want to include "index.php" in the path.
if
(
!
$asset
)
{
$base
.=
'/'
.
Config
::
get
(
'application.index'
);
}
if
(
strpos
(
$base
,
'http://'
)
===
0
and
$https
)
if
(
$https
and
strpos
(
$base
,
'http://'
)
===
0
)
{
{
$base
=
'https://'
.
substr
(
$base
,
7
);
$base
=
'https://'
.
substr
(
$base
,
7
);
}
}
return
rtrim
(
$base
,
'/'
)
.
'/'
.
trim
(
$url
,
'/'
);
return
$base
.
'/'
.
l
trim
(
$url
,
'/'
);
}
}
/**
/**
...
@@ -52,9 +46,9 @@ class URL {
...
@@ -52,9 +46,9 @@ class URL {
* @param string $url
* @param string $url
* @return string
* @return string
*/
*/
public
static
function
to_asset
(
$url
=
''
)
public
static
function
to_asset
(
$url
)
{
{
return
st
atic
::
to
(
$url
,
Request
::
is_secure
(),
true
);
return
st
r_replace
(
'/'
.
Config
::
get
(
'application.index'
),
''
,
static
::
to
(
$url
,
Request
::
is_secure
())
);
}
}
/**
/**
...
...
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