Commit 6833754d authored by alexpott's avatar alexpott

Issue #2409789 by mglaman, clemens.tolboom: Double slashes in canonicals while...

Issue #2409789 by mglaman, clemens.tolboom: Double slashes in canonicals while calling resourcePluginManager->getDefinitions()
parent c9ee3b52
......@@ -86,7 +86,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
// Check if there are link templates defined for the entity type and
// use the path from the route instead of the default.
if ($link_template = $entity_type->getLinkTemplate($link_relation)) {
$this->derivatives[$entity_type_id]['uri_paths'][$link_relation] = '/' . $link_template;
$this->derivatives[$entity_type_id]['uri_paths'][$link_relation] = $link_template;
}
else {
$this->derivatives[$entity_type_id]['uri_paths'][$link_relation] = $default_uri;
......
......@@ -106,4 +106,19 @@ public function testAuthentication() {
$this->curlClose();
}
/**
* Tests that resource URI paths are formatted properly.
*/
public function testUriPaths() {
$this->enableService('entity:entity_test');
/** @var \Drupal\rest\Plugin\Type\ResourcePluginManager $manager */
$manager = \Drupal::service('plugin.manager.rest');
foreach ($manager->getDefinitions() as $resource => $definition) {
foreach ($definition['uri_paths'] as $key => $uri_path) {
$this->assertFalse(strpos($uri_path, '//'), 'The resource URI path does not have duplicate slashes.');
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment