fix for incorrect version removal from URL
This commit is contained in:
commit
040cb49d29
4
.gitignore
vendored
4
.gitignore
vendored
@ -28,3 +28,7 @@ models/checksum.json
|
||||
.swp
|
||||
/nbproject
|
||||
.env
|
||||
|
||||
.docker
|
||||
docker*
|
||||
Makefile
|
||||
|
@ -28,7 +28,7 @@ class Utils
|
||||
*/
|
||||
public static function removeVersionFromUri(string $uri): string
|
||||
{
|
||||
return (string) preg_replace('/\/v\d{1,3}\/?/', '', $uri);
|
||||
return (string) preg_replace('#api/v\d{1,3}/?#', 'api', $uri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
37
tests/src/Component/UtilsTest.php
Normal file
37
tests/src/Component/UtilsTest.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\Tests\Component;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RetailCrm\Api\Component\Utils;
|
||||
|
||||
class UtilsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider removeVersionProvider
|
||||
*/
|
||||
public function testRemoveVersionFromUri(string $uri, string $expectedResult): void
|
||||
{
|
||||
$actualResult = Utils::removeVersionFromUri($uri);
|
||||
|
||||
self::assertEquals($expectedResult, $actualResult);
|
||||
}
|
||||
|
||||
public function removeVersionProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'https://v5gv5hv5fv5jv5v5fgv59hbfg9.retailcrm.io/api/v5',
|
||||
'https://v5gv5hv5fv5jv5v5fgv59hbfg9.retailcrm.io/api',
|
||||
],
|
||||
[
|
||||
'https://v5gv5hv5fv5jv5v5fgv59hbfg9.retailcrm.io/api/v5/',
|
||||
'https://v5gv5hv5fv5jv5v5fgv59hbfg9.retailcrm.io/api',
|
||||
],
|
||||
[
|
||||
'https://v5gv5hv5fv5jv5v5fgv59hbfg9.retailcrm.io',
|
||||
'https://v5gv5hv5fv5jv5v5fgv59hbfg9.retailcrm.io',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user