[limb-svn] r6973 - in 3.x/trunk/limb/net: src tests/cases

svn at limb-project.com svn at limb-project.com
Tue Apr 29 15:18:43 MSD 2008


Author: korchasa
Date: 2008-04-29 15:18:43 +0400 (Tue, 29 Apr 2008)
New Revision: 6973
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6973

Modified:
   3.x/trunk/limb/net/src/lmbUri.class.php
   3.x/trunk/limb/net/tests/cases/lmbUriTest.class.php
Log:
-- fix for file protocol uri with host

Modified: 3.x/trunk/limb/net/src/lmbUri.class.php
===================================================================
--- 3.x/trunk/limb/net/src/lmbUri.class.php	2008-04-29 09:04:20 UTC (rev 6972)
+++ 3.x/trunk/limb/net/src/lmbUri.class.php	2008-04-29 11:18:43 UTC (rev 6973)
@@ -70,8 +70,11 @@
 
   protected function _fixFileProtocol($url)
   {
-    if('/' != substr($url, 0, strlen('file:///')))
-      $url = str_replace('file://', 'file:///', $url);
+    $matches = array();
+    if(preg_match('/^file:\/\/([a-zA-Z]?:[\/].*)/', $url, $matches))
+      $url = 'file:///' . $matches[1];
+    //if('/' != substr($url, 0, strlen('file:///')))
+//      $url = str_replace('file://', 'file:///', $url);
     return $url;
   }
 

Modified: 3.x/trunk/limb/net/tests/cases/lmbUriTest.class.php
===================================================================
--- 3.x/trunk/limb/net/tests/cases/lmbUriTest.class.php	2008-04-29 09:04:20 UTC (rev 6972)
+++ 3.x/trunk/limb/net/tests/cases/lmbUriTest.class.php	2008-04-29 11:18:43 UTC (rev 6973)
@@ -36,28 +36,42 @@
 
   function testCreate_FileProtocolWithoutHost_OnUnix()
   {
-    $str = 'file://some_dir';
+    $str = 'file:///dir';
 
     $uri = new lmbUri($str);
 
     $this->assertEqual($uri->getProtocol(), 'file');
     $this->assertEqual($uri->getHost(), '');
 
-    $this->assertEqual($uri->getPath(), '/some_dir');
+    $this->assertEqual($uri->getPath(), '/dir');
   }
 
   function testCreate_FileProtocolWithoutHost_OnWindows()
   {
-    $str = 'file://c:/some_dir';
+    $str = 'file://c:/dir';
 
     $uri = new lmbUri($str);
 
     $this->assertEqual($uri->getProtocol(), 'file');
     $this->assertEqual($uri->getHost(), '');
 
-    $this->assertEqual($uri->getPath(), 'c:/some_dir');
+    $this->assertEqual($uri->getPath(), 'c:/dir');
   }
 
+
+  function testCreate_FileProtocolWithHost()
+  {
+    $str = 'file://user:pass@localhost/dir/file';
+
+    $uri = new lmbUri($str);
+
+    $this->assertEqual($uri->getProtocol(), 'file');
+    $this->assertEqual($uri->getUser(), 'user');
+    $this->assertEqual($uri->getPassword(), 'pass');
+    $this->assertEqual($uri->getHost(), 'localhost');
+    $this->assertEqual($uri->getPath(), '/dir/file');
+  }
+
   function testInvalidUriThrowsException()
   {
     try



More information about the limb-svn mailing list