Fix issue #779
diff --git a/system/core/URI.php b/system/core/URI.php
index 6a8b1a5..15e6a55 100644
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -165,11 +165,8 @@
 	 */
 	protected function _set_uri_string($str)
 	{
-		// Filter out control characters
-		$str = remove_invisible_characters($str, FALSE);
-
-		// If the URI contains only a slash we'll kill it
-		$this->uri_string = ($str === '/') ? '' : $str;
+		// Filter out control characters and trim slashes
+		$this->uri_string = trim(remove_invisible_characters($str, FALSE), '/');
 	}
 
 	// --------------------------------------------------------------------
diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php
index 60ed1a4..e2deabe 100644
--- a/tests/codeigniter/core/URI_test.php
+++ b/tests/codeigniter/core/URI_test.php
@@ -40,13 +40,13 @@
 			'/index.php?/controller/method/?var=foo' => 'controller/method'
 		);
 
-		foreach($requests as $request => $expected)
+		foreach ($requests as $request => $expected)
 		{
 			$_SERVER['SCRIPT_NAME'] = '/index.php';
 			$_SERVER['REQUEST_URI'] = $request;
 
 			$this->uri->_fetch_uri_string();
-			$this->assertEquals($expected, $this->uri->uri_string );
+			$this->assertEquals($expected, $this->uri->uri_string);
 		}
 
 		// Test a subfolder
@@ -60,10 +60,10 @@
 		unset($_SERVER['REQUEST_URI']);
 
 		// life to path info
-		$_SERVER['PATH_INFO'] = $a = '/controller/method/';
+		$_SERVER['PATH_INFO'] = '/controller/method/';
 
 		$this->uri->_fetch_uri_string();
-		$this->assertEquals($a, $this->uri->uri_string);
+		$this->assertEquals('controller/method', $this->uri->uri_string);
 
 		// death to path info
 		// At this point your server must be seriously drunk
@@ -72,7 +72,7 @@
 		$_SERVER['QUERY_STRING'] = '/controller/method/';
 
 		$this->uri->_fetch_uri_string();
-		$this->assertEquals($a, $this->uri->uri_string);
+		$this->assertEquals('controller/method', $this->uri->uri_string);
 
 		// At this point your server is a labotomy victim
 		unset($_SERVER['QUERY_STRING']);
@@ -80,7 +80,7 @@
 		$_GET['/controller/method/'] = '';
 
 		$this->uri->_fetch_uri_string();
-		$this->assertEquals($a, $this->uri->uri_string);
+		$this->assertEquals('controller/method', $this->uri->uri_string);
 
 		// Test coverage implies that these will work
 		// uri_protocol: REQUEST_URI
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index cd50378..f0a61d4 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -372,6 +372,7 @@
 -  Fixed a bug where :doc:`Email Library <libraries/email>` didn't honor it's *wordwrap* setting while handling alternative messages.
 -  Fixed a bug (#1476, #1909) - :doc:`Pagination Library <libraries/pagination>` didn't take into account actual routing when determining the current page.
 -  Fixed a bug (#1766) - :doc:`Query Builder <database/query_builder>` didn't always take into account the *dbprefix* setting.
+-  Fixed a bug (#779) - :doc:`URI Class <libraries/uri>` didn't always trim slashes from the *uri_string* as shown in the documentation.
 
 Version 2.1.3
 =============