Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
5068c578
Commit
5068c578
authored
11 years ago
by
Vincent Petry
Browse files
Options
Downloads
Plain Diff
Merge pull request #7613 from owncloud/fix_urlGenerator2
Add \OC::$WEBROOT to URLGenerator::getAbsoluteURL()
parents
2d592ddc
ada8d4e0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/urlgenerator.php
+2
-1
2 additions, 1 deletion
lib/private/urlgenerator.php
tests/lib/urlgenerator.php
+27
-3
27 additions, 3 deletions
tests/lib/urlgenerator.php
with
29 additions
and
4 deletions
lib/private/urlgenerator.php
+
2
−
1
View file @
5068c578
...
...
@@ -148,6 +148,7 @@ class URLGenerator implements IURLGenerator {
*/
public
function
getAbsoluteURL
(
$url
)
{
$separator
=
$url
[
0
]
===
'/'
?
''
:
'/'
;
return
\OC_Request
::
serverProtocol
()
.
'://'
.
\OC_Request
::
serverHost
()
.
$separator
.
$url
;
return
\OC_Request
::
serverProtocol
()
.
'://'
.
\OC_Request
::
serverHost
()
.
\OC
::
$WEBROOT
.
$separator
.
$url
;
}
}
This diff is collapsed.
Click to expand it.
tests/lib/urlgenerator.php
+
27
−
3
View file @
5068c578
...
...
@@ -12,17 +12,32 @@ class Test_Urlgenerator extends PHPUnit_Framework_TestCase {
/**
* @small
* @brief test absolute URL construction
* @dataProvider provideURLs
* @dataProvider provide
DocRoot
URLs
*/
function
testGetAbsoluteURL
(
$url
,
$expectedResult
)
{
function
testGetAbsoluteURL
DocRoot
(
$url
,
$expectedResult
)
{
\OC
::
$WEBROOT
=
''
;
$urlGenerator
=
new
\OC\URLGenerator
(
null
);
$result
=
$urlGenerator
->
getAbsoluteURL
(
$url
);
$this
->
assertEquals
(
$expectedResult
,
$result
);
}
public
function
provideURLs
()
{
/**
* @small
* @brief test absolute URL construction
* @dataProvider provideSubDirURLs
*/
function
testGetAbsoluteURLSubDir
(
$url
,
$expectedResult
)
{
\OC
::
$WEBROOT
=
'/owncloud'
;
$urlGenerator
=
new
\OC\URLGenerator
(
null
);
$result
=
$urlGenerator
->
getAbsoluteURL
(
$url
);
$this
->
assertEquals
(
$expectedResult
,
$result
);
}
public
function
provideDocRootURLs
()
{
return
array
(
array
(
"index.php"
,
"http://localhost/index.php"
),
array
(
"/index.php"
,
"http://localhost/index.php"
),
...
...
@@ -30,5 +45,14 @@ class Test_Urlgenerator extends PHPUnit_Framework_TestCase {
array
(
"apps/index.php"
,
"http://localhost/apps/index.php"
),
);
}
public
function
provideSubDirURLs
()
{
return
array
(
array
(
"index.php"
,
"http://localhost/owncloud/index.php"
),
array
(
"/index.php"
,
"http://localhost/owncloud/index.php"
),
array
(
"/apps/index.php"
,
"http://localhost/owncloud/apps/index.php"
),
array
(
"apps/index.php"
,
"http://localhost/owncloud/apps/index.php"
),
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment