Skip to content

Commit eb85f99

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-35806-All-Path-Params-Are-Lowercase' into develop
2 parents acd41e4 + 7c00cb9 commit eb85f99

File tree

4 files changed

+7
-30
lines changed

4 files changed

+7
-30
lines changed

app/code/Magento/Webapi/Controller/Rest/Router/Route.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected function getRouteParts()
6969
$this->variables[$key] = substr($value, 1);
7070
$value = null;
7171
}
72-
$result[$key] = strtolower($value);
72+
$result[$key] = $value;
7373
}
7474
return $result;
7575
}
@@ -92,19 +92,12 @@ protected function isVariable($value)
9292
/**
9393
* Retrieve unified requested path
9494
*
95-
* Lowercase all path chunks, except variables names.
96-
* E.g. the path '/V1/Categories/:categoryId' will be converted to '/v1/categories/:categoryId'.
97-
*
9895
* @param string $path
9996
* @return array
10097
*/
10198
protected function getPathParts($path)
10299
{
103-
$result = explode('/', trim($path, '/'));
104-
array_walk($result, function (&$item) {
105-
$item = substr($item, 0, 1) === ":" ? $item : strtolower($item);
106-
});
107-
return $result;
100+
return explode('/', trim($path, '/'));
108101
}
109102

110103
/**

app/code/Magento/Webapi/Model/Rest/Config.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function _createRoute($routeData)
6767
/** @var $route \Magento\Webapi\Controller\Rest\Router\Route */
6868
$route = $this->_routeFactory->createRoute(
6969
'Magento\Webapi\Controller\Rest\Router\Route',
70-
$this->_formatRoutePath($routeData[self::KEY_ROUTE_PATH])
70+
$routeData[self::KEY_ROUTE_PATH]
7171
);
7272

7373
$route->setServiceClass($routeData[self::KEY_CLASS])
@@ -78,22 +78,6 @@ protected function _createRoute($routeData)
7878
return $route;
7979
}
8080

81-
/**
82-
* Lowercase all parts of the given route path except for the path parameters.
83-
*
84-
* @param string $routePath The route path (e.g. '/V1/Categories/:categoryId')
85-
* @return string The modified route path (e.g. '/v1/categories/:categoryId')
86-
*/
87-
protected function _formatRoutePath($routePath)
88-
{
89-
$routePathParts = explode('/', $routePath);
90-
$pathParts = [];
91-
foreach ($routePathParts as $pathPart) {
92-
$pathParts[] = substr($pathPart, 0, 1) === ":" ? $pathPart : strtolower($pathPart);
93-
}
94-
return implode('/', $pathParts);
95-
}
96-
9781
/**
9882
* Get service base URL
9983
*

app/code/Magento/Webapi/Test/Unit/Controller/Rest/Router/RouteTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ public function dataProviderRoutes()
9595
['/V1/one/two/:threeValue/four/:fiveValue', '/V1/one/two/3/four/5', ['threeValue' => 3, 'fiveValue' => 5]],
9696

9797
['/v1/One', '/v1/One', []],
98-
['/v1/oNe', '/V1/one', []],
99-
['/v1/onE', '/V1/oNe', []],
10098

101-
['/v1/One/:twoValue', '/V1/one/2', ['twoValue' => 2]],
10299
['/v1/oNe/:TwoValue', '/v1/oNe/2', ['TwoValue' => 2]],
103100
['/v1/onE/:twovalue', '/v1/onE/2', ['twovalue' => 2]],
104101

@@ -108,6 +105,9 @@ public function dataProviderRoutes()
108105
['/V1/one-one/:two_value', '/V1/one-one/2', ['two_value' => 2]],
109106

110107
// Error
108+
['/v1/oNe', '/V1/one', false],
109+
['/v1/onE', '/V1/oNe', false],
110+
['/v1/One/:twoValue', '/V1/one/2', false],
111111
['/V1/one', '/V1/two', false],
112112
['/V1/one/:twoValue', '/V1/one', false],
113113
['/V1/one/two', '/V1/one', false],

dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function testOtherException()
8181
{
8282
$serviceInfo = [
8383
'rest' => [
84-
'resourcePath' => '/V1/errortest/otherexception',
84+
'resourcePath' => '/V1/errortest/otherException',
8585
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET,
8686
],
8787
];

0 commit comments

Comments
 (0)