commit 74e713d07db6611077ba771f6a4aac33229fae4e
Author: Ilias Dimopoulos <idimopoulos@hotmail.com>
Date:   Wed Apr 13 09:49:24 2016 +0200

    2671228 Test and patch.

diff --git a/src/Plugin/search_api/datasource/ContentEntity.php b/src/Plugin/search_api/datasource/ContentEntity.php
index 8d5993b..ab63cb5 100644
--- a/src/Plugin/search_api/datasource/ContentEntity.php
+++ b/src/Plugin/search_api/datasource/ContentEntity.php
@@ -368,7 +368,7 @@ class ContentEntity extends DatasourcePluginBase {
 
     $entity_ids = array();
     foreach ($ids as $item_id) {
-      list($entity_id, $langcode) = explode(':', $item_id, 2);
+      list($entity_id, $langcode) = preg_split('/:(?=[a-zA-Z0-9-]+$)/', $item_id);
       if (isset($allowed_languages[$langcode])) {
         $entity_ids[$entity_id][$item_id] = $langcode;
       }
diff --git a/src/Utility.php b/src/Utility.php
index 2cf7521..0df89b9 100644
--- a/src/Utility.php
+++ b/src/Utility.php
@@ -365,7 +365,8 @@ class Utility {
    *   might be NULL. If $separate_last is TRUE it's the exact other way round.
    */
   public static function splitPropertyPath($property_path, $separate_last = TRUE, $separator = ':') {
-    $function = $separate_last ? 'strrpos' : 'strpos';
+    $is_default_separator = $separator != IndexInterface::DATASOURCE_ID_SEPARATOR;
+    $function = $separate_last && $is_default_separator ? 'strrpos' : 'strpos';
     $pos = $function($property_path, $separator);
     if ($pos !== FALSE) {
       return array(
@@ -741,7 +742,7 @@ class Utility {
    *   element 0 will be NULL.
    */
   public static function splitCombinedId($combined_id) {
-    return static::splitPropertyPath($combined_id, TRUE, IndexInterface::DATASOURCE_ID_SEPARATOR);
+    return explode(IndexInterface::DATASOURCE_ID_SEPARATOR, $combined_id, 2);
   }
 
 }
diff --git a/tests/src/Kernel/EntityStringIdTest.php b/tests/src/Kernel/EntityStringIdTest.php
new file mode 100644
index 0000000..e3ccf2d
--- /dev/null
+++ b/tests/src/Kernel/EntityStringIdTest.php
@@ -0,0 +1,156 @@
+<?php
+
+namespace Drupal\Tests\search_api\Kernel;
+
+use Drupal\entity_test\Entity\EntityTestStringId;
+use Drupal\KernelTests\KernelTestBase;
+use Drupal\search_api\Entity\Index;
+use Drupal\search_api\Entity\Server;
+
+/**
+ * Tests entity indexing that are using string IDs.
+ *
+ * Current limit of the search_api ID is 50 characters. The format of the
+ * saved item is entity:<entity_type_id>/<entity_id>:<language_code>.
+
+ * @group search_api
+ */
+class EntityStringIdTest extends KernelTestBase {
+
+  /**
+   * The test entity type used in the test.
+   *
+   * @var string
+   */
+  protected $testEntityTypeId = 'entity_test_string_id';
+
+  /**
+   * The search server used for testing.
+   *
+   * @var \Drupal\search_api\ServerInterface
+   */
+  protected $server;
+
+  /**
+   * The search index used for testing.
+   *
+   * @var \Drupal\search_api\IndexInterface
+   */
+  protected $index;
+
+  /**
+   * Modules to enable for this test.
+   *
+   * @var string[]
+   */
+  public static $modules = array(
+    'search_api',
+    'search_api_test_backend',
+    'language',
+    'user',
+    'system',
+    'entity_test',
+  );
+
+  /**
+   * An array of langcodes.
+   *
+   * @var string[]
+   */
+  protected $langcodes;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setUp() {
+    parent::setUp();
+
+    $this->installSchema('search_api', array(
+      'search_api_item',
+      'search_api_task'
+    ));
+    $this->installEntitySchema('entity_test_string_id');
+
+    // Do not use a batch for tracking the initial items after creating an
+    // index when running the tests via the GUI. Otherwise, it seems Drupal's
+    // Batch API gets confused and the test fails.
+    \Drupal::state()->set('search_api_use_tracking_batch', FALSE);
+
+    // Create a test server.
+    $this->server = Server::create(array(
+      'name' => 'Test Server',
+      'id' => 'test_server',
+      'status' => 1,
+      'backend' => 'search_api_test_backend',
+    ));
+    $this->server->save();
+
+    // Create a test index.
+    $this->index = Index::create(array(
+      'name' => 'Test Index',
+      'id' => 'test_index',
+      'status' => 1,
+      'datasource_settings' => array(
+        'entity:' . $this->testEntityTypeId => array(
+          'plugin_id' => 'entity:' . $this->testEntityTypeId,
+          'settings' => array(),
+        ),
+      ),
+      'tracker_settings' => array(
+        'default' => array(
+          'plugin_id' => 'default',
+          'settings' => array(),
+        )
+      ),
+      'server' => $this->server->id(),
+      'options' => array('index_directly' => FALSE),
+    ));
+    $this->index->save();
+  }
+
+  /**
+   * Tests URIs as IDs.
+   *
+   * @param string $entity_id
+   *   A list of IDs to check.
+   *
+   * @dataProvider entityStringIdList
+   */
+  public function testUriStringId($entity_id) {
+    $entity = EntityTestStringId::create(array(
+      'id' => $entity_id,
+      'name' => 'String Test',
+      'user_id' => $this->container->get('current_user')->id(),
+    ));
+    $entity->save();
+
+    // Test that the datasource returns the correct item IDs.
+    $datasource = $this->index->getDatasource('entity:' . $this->testEntityTypeId);
+    $datasource_item_ids = $datasource->getItemIds();
+    sort($datasource_item_ids);
+    $expected = array(
+      $entity_id . ':und',
+    );
+    $this->assertEquals($expected, $datasource_item_ids, 'Datasource returns correct item ids.');
+
+    // Test indexing the new entitiy.
+    $this->assertEquals(0, $this->index->getTrackerInstance()->getIndexedItemsCount(), 'The index is empty.');
+    $this->assertEquals(1, $this->index->getTrackerInstance()->getTotalItemsCount(), 'There is one item to be indexed.');
+    $this->index->indexItems();
+    $this->assertEquals(1, $this->index->getTrackerInstance()->getIndexedItemsCount(), 'One item has been indexed.');
+  }
+
+  /**
+   * Provides string IDs to test.
+   *
+   * @return array
+   *   An array of arrays which contain a list of parameters to be
+   *   passed to the appropriate tests.
+   */
+  function entityStringIdList() {
+    return array(
+      ['short_string_id'], // Normal string matched by \w regex code.
+      ['http://drupal.org'], // Uri string not matched by \w regex code.
+    );
+  }
+}
