Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UrlScript is not standalone - it brokes expected getBasePath behavioral #100

Closed
SlavaAurim opened this issue Sep 3, 2016 · 1 comment
Closed

Comments

@SlavaAurim
Copy link

@SlavaAurim SlavaAurim commented Sep 3, 2016

I cannot use class Nette\HttpUrlScript "smoothly", as standalone (its needed for me for extending of Nette\Http\Request class).

For example:

$url = new \Nette\Http\UrlScript("http://nette.org/admin/script.php/pathinfo/?name=param#fragment");
echo $url->basePath; // expected '/admin/', but output is '/'

My suggestions:

You can specify in the constructor the minimum default functionality, suitable for most cases. My simple example:

class UrlScript extends Url
{
    ...

    public function __construct($url = NULL)
    {
        parent::__construct($url);
        $this->scriptPath =  $this->path;       
    }

    ...
}

With this patch any descendant class of UrlScript (if its instance was created standalone, not from RequestFactory), will have same behavioral as the class Url (in method getBasePath, getRelativeUrl and other).

@JanTvrdik

This comment has been minimized.

Copy link
Contributor

@JanTvrdik JanTvrdik commented Sep 4, 2016

Failing test

$a = new Url('http://nette.org/admin/script.php/pathinfo/?name=param#fragment');
$b = new UrlScript('http://nette.org/admin/script.php/pathinfo/?name=param#fragment');

Assert::same($a->getBasePath(), $b->getBasePath());
@dg dg closed this in f72d71d Sep 26, 2016
dg added a commit that referenced this issue Sep 27, 2016
…al as the class Url (in method getBasePath, ...) [Closes #100]

(possible BC break)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.