Skip to content

Commit 12ac75c

Browse files
committed
UrlScript: default scriptPath is whole path to maintain same behavioral as the class Url (in method getBasePath, ...) [Closes #100]
(possible BC break)
1 parent a24fc33 commit 12ac75c

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/Http/UrlScript.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
class UrlScript extends Url
2828
{
2929
/** @var string */
30-
private $scriptPath = '/';
30+
private $scriptPath;
3131

3232

3333
/**
@@ -48,7 +48,7 @@ public function setScriptPath($value)
4848
*/
4949
public function getScriptPath()
5050
{
51-
return $this->scriptPath;
51+
return $this->scriptPath ?: $this->path;
5252
}
5353

5454

@@ -58,7 +58,7 @@ public function getScriptPath()
5858
*/
5959
public function getBasePath()
6060
{
61-
$pos = strrpos($this->scriptPath, '/');
61+
$pos = strrpos($this->getScriptPath(), '/');
6262
return $pos === FALSE ? '' : substr($this->getPath(), 0, $pos + 1);
6363
}
6464

@@ -69,7 +69,7 @@ public function getBasePath()
6969
*/
7070
public function getPathInfo()
7171
{
72-
return (string) substr($this->getPath(), strlen($this->scriptPath));
72+
return (string) substr($this->getPath(), strlen($this->getScriptPath()));
7373
}
7474

7575
}

tests/Http/UrlScript.parse.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ require __DIR__ . '/../bootstrap.php';
1212

1313

1414
$url = new UrlScript('http://nette.org:8080/file.php?q=search');
15-
Assert::same('/', $url->scriptPath);
15+
Assert::same('/file.php', $url->scriptPath);
1616
Assert::same('http://nette.org:8080/', $url->baseUrl);
1717
Assert::same('/', $url->basePath);
1818
Assert::same('file.php?q=search', $url->relativeUrl);
19-
Assert::same('file.php', $url->pathInfo);
19+
Assert::same('', $url->pathInfo);

0 commit comments

Comments
 (0)