Skip to content

Commit c72464a

Browse files
authored
Merge pull request #43 from lamasgergo/master
Force https else use same protocol as site has
2 parents 192517e + af5bb4a commit c72464a

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/View/Helper/GoogleMapHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ protected function _protocol() {
16721672
if ($https === null) {
16731673
$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
16741674
}
1675-
return ($https ? 'https' : 'http') . '://';
1675+
return $https ? 'https://' : '//';
16761676
}
16771677

16781678
/**

tests/TestCase/View/Helper/GoogleMapHelperTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ public function testConfigMergeDeep() {
7676
*/
7777
public function testApiUrl() {
7878
$result = $this->GoogleMap->apiUrl();
79-
$this->assertSame('http://maps.google.com/maps/api/js?v=3', $result);
79+
$this->assertSame('//maps.google.com/maps/api/js?v=3', $result);
8080

8181
$result = $this->GoogleMap->apiUrl(['foo' => '<b>Bar</b>']);
82-
$this->assertSame('http://maps.google.com/maps/api/js?foo=%3Cb%3EBar%3C%2Fb%3E&v=3', $result);
82+
$this->assertSame('//maps.google.com/maps/api/js?foo=%3Cb%3EBar%3C%2Fb%3E&v=3', $result);
8383
}
8484

8585
/**
@@ -100,18 +100,18 @@ public function testIcon() {
100100
*/
101101
public function testMapUrl() {
102102
$url = $this->GoogleMap->mapUrl(['to' => 'Munich, Germany']);
103-
$this->assertEquals('http://maps.google.com/maps?daddr=Munich%2C+Germany', $url);
103+
$this->assertEquals('//maps.google.com/maps?daddr=Munich%2C+Germany', $url);
104104

105105
$url = $this->GoogleMap->mapUrl(['to' => '<München>, Germany', 'zoom' => 1]);
106-
$this->assertEquals('http://maps.google.com/maps?daddr=%3CM%C3%BCnchen%3E%2C+Germany&amp;z=1', $url);
106+
$this->assertEquals('//maps.google.com/maps?daddr=%3CM%C3%BCnchen%3E%2C+Germany&amp;z=1', $url);
107107
}
108108

109109
/**
110110
* @return void
111111
*/
112112
public function testMapLink() {
113113
$result = $this->GoogleMap->mapLink('<To Munich>!', ['to' => '<Munich>, Germany', 'zoom' => 10]);
114-
$expected = '<a href="http://maps.google.com/maps?daddr=%3CMunich%3E%2C+Germany&amp;z=10">&lt;To Munich&gt;!</a>';
114+
$expected = '<a href="//maps.google.com/maps?daddr=%3CMunich%3E%2C+Germany&amp;z=10">&lt;To Munich&gt;!</a>';
115115
$this->assertEquals($expected, $result);
116116
}
117117

@@ -121,7 +121,7 @@ public function testMapLink() {
121121
public function testLinkWithMapUrl() {
122122
$url = $this->GoogleMap->mapUrl(['to' => '<München>, Germany', 'zoom' => 10, 'escape' => false]);
123123
$result = $this->GoogleMap->Html->link('Some title', $url);
124-
$expected = '<a href="http://maps.google.com/maps?daddr=%3CM%C3%BCnchen%3E%2C+Germany&amp;z=10">Some title</a>';
124+
$expected = '<a href="//maps.google.com/maps?daddr=%3CM%C3%BCnchen%3E%2C+Germany&amp;z=10">Some title</a>';
125125
$this->assertEquals($expected, $result);
126126
}
127127

@@ -214,11 +214,11 @@ public function testStatic() {
214214
];
215215

216216
$is = $this->GoogleMap->staticMapUrl($options);
217-
$expected = 'http://maps.google.com/maps/api/staticmap?size=300x300&amp;format=png&amp;mobile=false&amp;maptype=roadmap&amp;markers=color:yellow|shadow:true|Berlin&amp;markers=color:0x0000FF|shadow:false|44.2%2C11.1';
217+
$expected = '//maps.google.com/maps/api/staticmap?size=300x300&amp;format=png&amp;mobile=false&amp;maptype=roadmap&amp;markers=color:yellow|shadow:true|Berlin&amp;markers=color:0x0000FF|shadow:false|44.2%2C11.1';
218218
$this->assertSame($expected, $is);
219219

220220
$is = $this->GoogleMap->staticMapLink('MyLink', $options);
221-
$expected = '<a href="http://maps.google.com/maps/api/staticmap?size=300x300&amp;format=png&amp;mobile=false&amp;maptype=roadmap&amp;markers=color:yellow|shadow:true|Berlin&amp;markers=color:0x0000FF|shadow:false|44.2%2C11.1">MyLink</a>';
221+
$expected = '<a href="//maps.google.com/maps/api/staticmap?size=300x300&amp;format=png&amp;mobile=false&amp;maptype=roadmap&amp;markers=color:yellow|shadow:true|Berlin&amp;markers=color:0x0000FF|shadow:false|44.2%2C11.1">MyLink</a>';
222222
$this->assertSame($expected, $is);
223223

224224
$is = $this->GoogleMap->staticMap($options);
@@ -236,7 +236,7 @@ public function testStatic() {
236236
'title' => '<b>Yeah!</b>'
237237
];
238238
$is = $this->GoogleMap->staticMap($options, $attr);
239-
$expected = '<img src="http://maps.google.com/maps/api/staticmap?size=200x100&amp;format=png&amp;mobile=false&amp;center=1&amp;maptype=roadmap" title="&lt;b&gt;Yeah!&lt;/b&gt;" alt="Map"/>';
239+
$expected = '<img src="//maps.google.com/maps/api/staticmap?size=200x100&amp;format=png&amp;mobile=false&amp;center=1&amp;maptype=roadmap" title="&lt;b&gt;Yeah!&lt;/b&gt;" alt="Map"/>';
240240
$this->assertSame($expected, $is);
241241

242242
$pos = [
@@ -251,16 +251,16 @@ public function testStatic() {
251251
'url' => $this->GoogleMap->mapUrl(['to' => 'Munich, Germany', 'zoom' => 10, 'escape' => false])
252252
];
253253
$is = $this->GoogleMap->staticMap($options, $attr);
254-
$this->assertTextContains('href="http://maps.google.com/maps?daddr=Munich%2C+Germany&amp;z=10"', $is);
254+
$this->assertTextContains('href="//maps.google.com/maps?daddr=Munich%2C+Germany&amp;z=10"', $is);
255255

256256
$url = $this->GoogleMap->mapUrl(['to' => 'Munich, Germany', 'zoom' => 10, 'escape' => false]);
257257
$attr = [
258258
'title' => 'Yeah'
259259
];
260260
$image = $this->GoogleMap->staticMap($options, $attr);
261261
$link = $this->GoogleMap->Html->link($image, $url, ['escapeTitle' => false, 'target' => '_blank']);
262-
$this->assertTextContains('href="http://maps.google.com/maps?daddr=Munich%2C+Germany&amp;z=10" target="_blank"', $link);
263-
$this->assertTextContains('src="http://maps.google.com/maps/api/staticmap?size=300x300&amp;format=png', $link);
262+
$this->assertTextContains('href="//maps.google.com/maps?daddr=Munich%2C+Germany&amp;z=10" target="_blank"', $link);
263+
$this->assertTextContains('src="//maps.google.com/maps/api/staticmap?size=300x300&amp;format=png', $link);
264264
}
265265

266266
/**
@@ -310,7 +310,7 @@ public function testMap() {
310310
$expected = '<div id="map_canvas" class="map"';
311311
$this->assertTextContains($expected, $result);
312312

313-
$expected = '<script src="http://maps.google.com/maps/api/js';
313+
$expected = '<script src="//maps.google.com/maps/api/js';
314314
$this->assertTextNotContains($expected, $result);
315315

316316
$expected = 'var map0 = new google.maps.Map(document.getElementById("map_canvas"), myOptions);';
@@ -320,7 +320,7 @@ public function testMap() {
320320
$this->assertTextContains($expected, $result);
321321

322322
$scripts = $this->View->fetch('script');
323-
$expected = '<script src="http://maps.google.com/maps/api/js';
323+
$expected = '<script src="//maps.google.com/maps/api/js';
324324
$this->assertTextContains($expected, $scripts);
325325
}
326326

@@ -343,7 +343,7 @@ public function testMapInlineScript() {
343343
$expected = '<div id="map_canvas" class="map"';
344344
$this->assertTextContains($expected, $result);
345345

346-
$expected = '<script src="http://maps.google.com/maps/api/js';
346+
$expected = '<script src="//maps.google.com/maps/api/js';
347347
$this->assertTextContains($expected, $result);
348348
}
349349

0 commit comments

Comments
 (0)