Skip to content

Commit 417d005

Browse files
author
Zuken
committed
Fix Request::segments() ignore segment "0"
1 parent 01896db commit 417d005

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/Illuminate/Http/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function segments()
114114
{
115115
$segments = explode('/', $this->path());
116116

117-
return array_values(array_filter($segments));
117+
return array_values(array_filter($segments, function($v) {return $v!='';} ));
118118
}
119119

120120
/**

tests/Http/HttpRequestTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public function segmentsProvider()
7878
return array(
7979
array('', array()),
8080
array('foo/bar', array('foo', 'bar')),
81-
array('foo/bar//baz', array('foo', 'bar', 'baz'))
81+
array('foo/bar//baz', array('foo', 'bar', 'baz')),
82+
array('foo/0/bar', array('foo', '0', 'bar'))
8283
);
8384
}
8485

0 commit comments

Comments
 (0)