Skip to content

Commit

Permalink
verify exists index 0 in $ref
Browse files Browse the repository at this point in the history
exemple

i have to get the referrer url from any page if exists

```
class AppController extends Controller {
......
    public function beforeRender() {
        parent::beforeRender();
        $this->params['referer'] = $this->referer(null, true);
    }
..........
}
```
  • Loading branch information
phlyper committed Feb 26, 2016
1 parent 1709f54 commit 7b9ff1c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeRequest.php
Expand Up @@ -448,7 +448,7 @@ public function referer($local = false) {
if (!empty($ref) && !empty($base)) {
if ($local && strpos($ref, $base) === 0) {
$ref = substr($ref, strlen($base));
if ($ref[0] !== '/') {
if (isset($ref[0]) && $ref[0] !== '/') {
$ref = '/' . $ref;
}
return $ref;
Expand Down

0 comments on commit 7b9ff1c

Please sign in to comment.