浏览代码

Fix full base URL.

mscherer 5 年之前
父节点
当前提交
d814153696

+ 2 - 2
src/View/Helper/CommonHelper.php

@@ -160,7 +160,7 @@ class CommonHelper extends Helper {
 	 * @return string HTML Markup
 	 * @return string HTML Markup
 	 */
 	 */
 	public function metaCanonical($url = null, bool $full = false): string {
 	public function metaCanonical($url = null, bool $full = false): string {
-		$canonical = $this->Url->build($url, ['full' => $full]);
+		$canonical = $this->Url->build($url, ['fullBase' => $full]);
 		$options = ['rel' => 'canonical', 'link' => $canonical];
 		$options = ['rel' => 'canonical', 'link' => $canonical];
 
 
 		return $this->Html->meta($options);
 		return $this->Html->meta($options);
@@ -179,7 +179,7 @@ class CommonHelper extends Helper {
 	 * @return string HTML Markup
 	 * @return string HTML Markup
 	 */
 	 */
 	public function metaAlternate($url, $lang, bool $full = false): string {
 	public function metaAlternate($url, $lang, bool $full = false): string {
-		$url = $this->Url->build($url, ['full' => $full]);
+		$url = $this->Url->build($url, ['fullBase' => $full]);
 		$lang = (array)$lang;
 		$lang = (array)$lang;
 		$res = [];
 		$res = [];
 		foreach ($lang as $language => $countries) {
 		foreach ($lang as $language => $countries) {

+ 2 - 2
src/View/Helper/QrCodeHelper.php

@@ -136,7 +136,7 @@ class QrCodeHelper extends Helper {
 			case 'text':
 			case 'text':
 				break;
 				break;
 			case 'url':
 			case 'url':
-				$text = $this->Url->build($text, ['full' => true]);
+				$text = $this->Url->build($text, ['fullBase' => true]);
 
 
 				break;
 				break;
 			case 'sms':
 			case 'sms':
@@ -246,7 +246,7 @@ class QrCodeHelper extends Helper {
 				case 'url':
 				case 'url':
 					$val = (array)$val;
 					$val = (array)$val;
 					foreach ($val as $v) {
 					foreach ($val as $v) {
-						$res[] = 'URL:' . $this->Url->build($v, ['full' => true]);
+						$res[] = 'URL:' . $this->Url->build($v, ['fullBase' => true]);
 					}
 					}
 
 
 					break;
 					break;

+ 8 - 8
tests/TestCase/View/Helper/CommonHelperTest.php

@@ -106,7 +106,7 @@ class CommonHelperTest extends TestCase {
 		$this->assertEquals('<link href="' . $this->Common->Url->build('/some/url/param1') . '" rel="canonical"/>', trim($is));
 		$this->assertEquals('<link href="' . $this->Common->Url->build('/some/url/param1') . '" rel="canonical"/>', trim($is));
 
 
 		$is = $this->Common->metaCanonical('/some/url/param1', true);
 		$is = $this->Common->metaCanonical('/some/url/param1', true);
-		$this->assertEquals('<link href="' . $this->Common->Url->build('/some/url/param1', ['full' => true]) . '" rel="canonical"/>', trim($is));
+		$this->assertEquals('<link href="' . $this->Common->Url->build('/some/url/param1', ['fullBase' => true]) . '" rel="canonical"/>', trim($is));
 	}
 	}
 
 
 	/**
 	/**
@@ -114,19 +114,19 @@ class CommonHelperTest extends TestCase {
 	 */
 	 */
 	public function testMetaAlternate() {
 	public function testMetaAlternate() {
 		$is = $this->Common->metaAlternate('/some/url/param1', 'de-de', true);
 		$is = $this->Common->metaAlternate('/some/url/param1', 'de-de', true);
-		$this->assertEquals('<link href="' . $this->Common->Url->build('/some/url/param1', ['full' => true]) . '" rel="alternate" hreflang="de-de"/>', trim($is));
+		$this->assertEquals('<link href="' . $this->Common->Url->build('/some/url/param1', ['fullBase' => true]) . '" rel="alternate" hreflang="de-de"/>', trim($is));
 
 
 		$is = $this->Common->metaAlternate(['controller' => 'Some', 'action' => 'url'], 'de', true);
 		$is = $this->Common->metaAlternate(['controller' => 'Some', 'action' => 'url'], 'de', true);
-		$this->assertEquals('<link href="' . $this->Common->Url->build('/some/url', ['full' => true]) . '" rel="alternate" hreflang="de"/>', trim($is));
+		$this->assertEquals('<link href="' . $this->Common->Url->build('/some/url', ['fullBase' => true]) . '" rel="alternate" hreflang="de"/>', trim($is));
 
 
 		$is = $this->Common->metaAlternate(['controller' => 'Some', 'action' => 'url'], ['de', 'de-ch'], true);
 		$is = $this->Common->metaAlternate(['controller' => 'Some', 'action' => 'url'], ['de', 'de-ch'], true);
-		$this->assertEquals('<link href="' . $this->Common->Url->build('/some/url', ['full' => true]) . '" rel="alternate" hreflang="de"/>' . PHP_EOL . '<link href="' . $this->Common->Url->build('/some/url', ['full' => true]) . '" rel="alternate" hreflang="de-ch"/>', trim($is));
+		$this->assertEquals('<link href="' . $this->Common->Url->build('/some/url', ['fullBase' => true]) . '" rel="alternate" hreflang="de"/>' . PHP_EOL . '<link href="' . $this->Common->Url->build('/some/url', ['fullBase' => true]) . '" rel="alternate" hreflang="de-ch"/>', trim($is));
 
 
 		$is = $this->Common->metaAlternate(['controller' => 'Some', 'action' => 'url'], ['de' => ['ch', 'at'], 'en' => ['gb', 'us']], true);
 		$is = $this->Common->metaAlternate(['controller' => 'Some', 'action' => 'url'], ['de' => ['ch', 'at'], 'en' => ['gb', 'us']], true);
-		$this->assertEquals('<link href="' . $this->Common->Url->build('/some/url', ['full' => true]) . '" rel="alternate" hreflang="de-ch"/>' . PHP_EOL .
-			'<link href="' . $this->Common->Url->build('/some/url', ['full' => true]) . '" rel="alternate" hreflang="de-at"/>' . PHP_EOL .
-			'<link href="' . $this->Common->Url->build('/some/url', ['full' => true]) . '" rel="alternate" hreflang="en-gb"/>' . PHP_EOL .
-			'<link href="' . $this->Common->Url->build('/some/url', ['full' => true]) . '" rel="alternate" hreflang="en-us"/>', trim($is));
+		$this->assertEquals('<link href="' . $this->Common->Url->build('/some/url', ['fullBase' => true]) . '" rel="alternate" hreflang="de-ch"/>' . PHP_EOL .
+			'<link href="' . $this->Common->Url->build('/some/url', ['fullBase' => true]) . '" rel="alternate" hreflang="de-at"/>' . PHP_EOL .
+			'<link href="' . $this->Common->Url->build('/some/url', ['fullBase' => true]) . '" rel="alternate" hreflang="en-gb"/>' . PHP_EOL .
+			'<link href="' . $this->Common->Url->build('/some/url', ['fullBase' => true]) . '" rel="alternate" hreflang="en-us"/>', trim($is));
 	}
 	}
 
 
 	/**
 	/**

+ 1 - 1
tests/TestCase/View/Helper/QrCodeHelperTest.php

@@ -63,7 +63,7 @@ class QrCodeHelperTest extends TestCase {
 	 */
 	 */
 	public function testFormatText() {
 	public function testFormatText() {
 		$is = $this->QrCode->formatText(['controller' => 'Foo', 'action' => 'bar'], 'url');
 		$is = $this->QrCode->formatText(['controller' => 'Foo', 'action' => 'bar'], 'url');
-		$this->assertSame('/foo/bar', $is);
+		$this->assertSame('//localhost/foo/bar', $is);
 	}
 	}
 
 
 	/**
 	/**

+ 1 - 1
tests/bootstrap.php

@@ -37,7 +37,7 @@ require_once 'vendor/autoload.php';
 Cake\Core\Configure::write('App', [
 Cake\Core\Configure::write('App', [
 	'namespace' => 'TestApp',
 	'namespace' => 'TestApp',
 	'encoding' => 'UTF-8',
 	'encoding' => 'UTF-8',
-	'fullBaseUrl' => '/',
+	'fullBaseUrl' => '//localhost',
 	'paths' => [
 	'paths' => [
 		'templates' => [
 		'templates' => [
 			TESTS . 'templates' . DS,
 			TESTS . 'templates' . DS,