8000 Merge pull request #730 from sparksp/develop-default-https · laravel/laravel@bc67c66 · GitHub
[go: up one dir, main page]

Skip to content

Commit bc67c66

Browse files
committed
Merge pull request #730 from sparksp/develop-default-https
Generated URLs default to use the current protocol (http or https)
2 parents cf604d4 + 6151886 commit bc67c66

File tree

6 files changed

+16
-17
lines changed

6 files changed

+16
-17
lines changed

laravel/form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function macro($name, $macro)
5151
* @param bool $https
5252
* @return string
5353
*/
54-
public static function open($action = null, $method = 'POST', $attributes = array(), $https = false)
54+
public static function open($action = null, $method = 'POST', $attributes = array(), $https = null)
5555
{
5656
$method = strtoupper($method);
5757

@@ -129,7 +129,7 @@ public static function open_secure($action = null, $method = 'POST', $attributes
129129
* @param bool $https
130130
* @return string
131131
*/
132-
public static function open_for_files($action = null, $method = 'POST', $attributes = array(), $https = false)
132+
public static function open_for_files($action = null, $method = 'POST', $attributes = array(), $https = null)
133133
{
134134
$attributes['enctype'] = 'multipart/form-data';
135135

laravel/helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ function head($array)
323323
* @param bool $https
324324
* @return string
325325
*/
326-
function url($url = '', $https = false)
326+
function url($url = '', $https = null)
327327
{
328328
return Laravel\URL::to($url, $https);
329329
}
@@ -335,7 +335,7 @@ function url($url = '', $https = false)
335335
* @param bool $https
336336
* @return string
337337
*/
338-
function asset($url, $https = false)
338+
function asset($url, $https = null)
339339
{
340340
return Laravel\URL::to_asset($url, $https);
341341
}

laravel/html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static function span($value, $attributes = array())
137137
* @param bool $https
138138
* @return string
139139
*/
140-
public static function link($url, $title, $attributes = array(), $https = false)
140+
public static function link($url, $title, $attributes = array(), $https = null)
141141
{
142142
$url = URL::to($url, $https);
143143

laravel/redirect.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Redirect extends Response {
99
* @param bool $secure
1010
* @return Redirect
1111
*/
12-
public static function home($status = 302, $https = false)
12+
public static function home($status = 302, $https = null)
1313
{
1414
return static::to(URL::home($https), $status);
1515
}
@@ -41,7 +41,7 @@ public static function back($status = 302)
4141
* @param bool $https
4242
* @return Redirect
4343
*/
44-
public static function to($url, $status = 302, $https = false)
44+
public static function to($url, $status = 302, $https = null)
4545
{
4646
return static::make('', $status)->header('Location', URL::to($url, $https));
4747
}

laravel/routing/router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ public static function secure_controller($controllers, $defaults = 'index')
297297
* @param bool $https
298298
* @return void
299299
*/
300-
public static function controller($controllers, $defaults = 'index', $https = false)
300+
public static function controller($controllers, $defaults = 'index', $https = null)
301301
{
302302
foreach ((array) $controllers as $identifier)
303303
{

laravel/url.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static function current()
3535
* @param bool $https
3636
* @return string
3737
*/
38-
public static function home($https = false)
38+
public static function home($https = null)
3939
{
4040
$route = Router::find('home');
4141

@@ -91,7 +91,7 @@ public static function base()
9191
* @param bool $https
9292
* @return string
9393
*/
94-
public static function to($url = '', $https = false)
94+
public static function to($url = '', $https = null)
9595
{
9696
// If the given URL is already valid or begins with a hash, we'll just return
9797
// the URL unchanged since it is already well formed. Otherwise we will add
@@ -101,6 +101,10 @@ public static function to($url = '', $https = false)
101101
return $url;
102102
}
103103

104+
// Unless $https is specified (true or false) then maintain the current request
105+
// security for any new links generated. So https for all secure links.
106+
if (is_null($https)) $https = Request::secure();
107+
104108
$root = static::base().'/'.Config::get('application.index');
105109

106110
// Since SSL is not often used while developing the application, we allow the
@@ -174,7 +178,7 @@ public static function to_action($action, $parameters = array())
174178
*/
175179
protected static function explicit($route, $action, $parameters)
176180
{
177-
$https = array_get(current($route), 'https', false);
181+
$https = array_get(current($route), 'https', null);
178182

179183
return static::to(static::transpose(key($route), $parameters), $https);
180184
}
@@ -197,8 +201,6 @@ protected static function convention($action, $parameters)
197201
// URIs that begin with that string and no others.
198202
$root = $bundle['handles'] ?: '';
199203

200-
$https = false;
201-
202204
$parameters = implode('/', $parameters);
203205

204206
// We'll replace both dots and @ signs in the URI since both are used
@@ -230,8 +232,6 @@ public static function to_asset($url, $https = null)
230232
return rtrim($root, '/').'/'.ltrim($url, '/');
231233
}
232234

233-
if (is_null($https)) $https = Request::secure();
234-
235235
$url = static::to($url, $https);
236236

237237
// Since assets are not served by Laravel, we do not need to come through
@@ -258,7 +258,6 @@ public static function to_asset($url, $https = null)
258258
*
259259
* @param string $name
260260
* @param array $parameters
261-
* @param bool $https
262261
* @return string
263262
*/
264263
public static function to_route($name, $parameters = array())
@@ -271,7 +270,7 @@ public static function to_route($name, $parameters = array())
271270
// To determine whether the URL should be HTTPS or not, we look for the "https"
272271
// value on the route action array. The route has control over whether the URL
273272
// should be generated with an HTTPS protocol string or just HTTP.
274-
$https = array_get(current($route), 'https', false);
273+
$https = array_get(current($route), 'https', null);
275274

276275
$uri = trim(static::transpose(key($route), $parameters), '/');
277276

0 commit comments

Comments
 (0)
0