mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Allow dashes in the CLI segment. Fixes #3205
This commit is contained in:
parent
dbadbaa1e9
commit
f1ac24cd7c
@ -868,7 +868,7 @@ class CLI
|
||||
{
|
||||
// If there's no '-' at the beginning of the argument
|
||||
// then add it to our segments.
|
||||
if (mb_strpos($_SERVER['argv'][$i], '-') === false)
|
||||
if (mb_strpos($_SERVER['argv'][$i], '-') !== 0)
|
||||
{
|
||||
static::$segments[] = $_SERVER['argv'][$i];
|
||||
continue;
|
||||
|
@ -223,7 +223,7 @@ class CLIRequest extends Request
|
||||
{
|
||||
// If there's no '-' at the beginning of the argument
|
||||
// then add it to our segments.
|
||||
if (! $options_found && strpos($argv[$i], '-') === false)
|
||||
if (! $options_found && strpos($argv[$i], '-') !== 0)
|
||||
{
|
||||
$this->segments[] = filter_var($argv[$i], FILTER_SANITIZE_STRING);
|
||||
continue;
|
||||
|
@ -283,14 +283,15 @@ class CLITest extends \CodeIgniter\Test\CIUnitTestCase
|
||||
'-parm',
|
||||
'pvalue',
|
||||
'd2',
|
||||
'da-sh',
|
||||
];
|
||||
$_SERVER['argc'] = 7;
|
||||
$_SERVER['argc'] = 8;
|
||||
CLI::init();
|
||||
$this->assertEquals(null, CLI::getSegment(7));
|
||||
$this->assertEquals('b', CLI::getSegment(1));
|
||||
$this->assertEquals('c', CLI::getSegment(2));
|
||||
$this->assertEquals('d', CLI::getSegment(3));
|
||||
$this->assertEquals(['b', 'c', 'd', 'd2'], CLI::getSegments());
|
||||
$this->assertEquals(['b', 'c', 'd', 'd2', 'da-sh'], CLI::getSegments());
|
||||
}
|
||||
|
||||
public function testParseCommandOption()
|
||||
|
@ -164,7 +164,7 @@ class CLIRequestTest extends \CodeIgniter\Test\CIUnitTestCase
|
||||
$this->request = new CLIRequest(new App());
|
||||
|
||||
$expectedOptions = '-foo bar -baz "queue some stuff"';
|
||||
$expectedPath = 'users/21';
|
||||
$expectedPath = 'users/21/pro-file';
|
||||
$this->assertEquals($expectedOptions, $this->request->getOptionString());
|
||||
$this->assertEquals($expectedPath, $this->request->getPath());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user