From 8f8f1071162c1bef8b0bc53ed7b435d342b81308 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 16 Jul 2017 21:06:54 +0200 Subject: [PATCH] Presenter::$absoluteUrls fixed --- src/Application/UI/Presenter.php | 2 +- tests/UI/Presenter.link().php71.phpt | 6 ++++++ tests/UI/Presenter.link().phpt | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index e5981b035..531c0eaac 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -966,7 +966,7 @@ protected function createRequest($component, $destination, array $args, $mode) return $mode === 'forward' || $mode === 'test' ? null - : $this->requestToUrl($this->lastCreatedRequest, $mode === 'link' && $scheme === false) . $fragment; + : $this->requestToUrl($this->lastCreatedRequest, $mode === 'link' && $scheme === false && !$this->absoluteUrls) . $fragment; } diff --git a/tests/UI/Presenter.link().php71.phpt b/tests/UI/Presenter.link().php71.phpt index efa4901d8..17848a83c 100644 --- a/tests/UI/Presenter.link().php71.phpt +++ b/tests/UI/Presenter.link().php71.phpt @@ -90,7 +90,13 @@ class TestPresenter extends Application\UI\Presenter // special url Assert::same('/index.php?x=1&y=2&action=product&presenter=Test', $this->link('product?x=1&y=2')); Assert::same('/index.php?x=1&y=2&action=product&presenter=Test#fragment', $this->link('product?x=1&y=2#fragment')); + + // absolute + Assert::same('http://localhost/index.php?x=1&y=2&action=product&presenter=Test#fragment', $this->link('//product?x=1&y=2#fragment')); + $this->absoluteUrls = TRUE; + Assert::same('http://localhost/index.php?x=1&y=2&action=product&presenter=Test#fragment', $this->link('product?x=1&y=2#fragment')); Assert::same('http://localhost/index.php?x=1&y=2&action=product&presenter=Test#fragment', $this->link('//product?x=1&y=2#fragment')); + $this->absoluteUrls = FALSE; // persistent params Assert::same('/index.php?action=params&presenter=Test', $this->link('params', ['pint' => $this->pint, 'p' => ''])); diff --git a/tests/UI/Presenter.link().phpt b/tests/UI/Presenter.link().phpt index 9b25be01c..86654707e 100644 --- a/tests/UI/Presenter.link().phpt +++ b/tests/UI/Presenter.link().phpt @@ -89,7 +89,13 @@ class TestPresenter extends Application\UI\Presenter // special url Assert::same('/index.php?x=1&y=2&action=product&presenter=Test', $this->link('product?x=1&y=2')); Assert::same('/index.php?x=1&y=2&action=product&presenter=Test#fragment', $this->link('product?x=1&y=2#fragment')); + + // absolute + Assert::same('http://localhost/index.php?x=1&y=2&action=product&presenter=Test#fragment', $this->link('//product?x=1&y=2#fragment')); + $this->absoluteUrls = TRUE; + Assert::same('http://localhost/index.php?x=1&y=2&action=product&presenter=Test#fragment', $this->link('product?x=1&y=2#fragment')); Assert::same('http://localhost/index.php?x=1&y=2&action=product&presenter=Test#fragment', $this->link('//product?x=1&y=2#fragment')); + $this->absoluteUrls = FALSE; // persistent params Assert::same('/index.php?action=params&presenter=Test', $this->link('params', ['pint' => $this->pint, 'p' => '']));