protected function _getHttpBasePathOffsetLevel($uri) { if (!$this->path_offset) { return 0; } $base_path_uri = new lmbUri(rtrim($this->base_path, '/')); $base_path_uri->normalizePath(); $level = 1; while ($uri->getPathElement($level) == $base_path_uri->getPathElement($level) && $level < $base_path_uri->countPath()) { $level++; } return $level; }
function testNormalizePath() { $uri = new lmbUri('/foo/bar/../boo.php'); $uri->normalizePath(); $this->assertEqual($uri, new lmbUri('/foo/boo.php')); $uri->reset('/foo/bar/../../boo.php'); $uri->normalizePath(); $this->assertEqual($uri, new lmbUri('/boo.php')); $uri->reset('/foo/bar/../boo.php'); $uri->normalizePath(); $this->assertEqual($uri, new lmbUri('/foo/boo.php')); $uri->reset('/foo//bar//boo.php'); $uri->normalizePath(); $this->assertEqual($uri, new lmbUri('/foo/bar/boo.php')); $uri->reset('/foo//bar///boo.php'); $uri->normalizePath(); $this->assertEqual($uri, $uri = new lmbUri('/foo/bar/boo.php')); $this->assertEqual($uri->getPath(), $uri->getPath()); }
protected function _getHttpBasePathOffsetLevel($uri) { if (!lmb_env_get('LIMB_HTTP_OFFSET_PATH')) { return 0; } $base_path = $uri->toString(array('protocol', 'user', 'password', 'host', 'port')) . '/' . lmb_env_get('LIMB_HTTP_OFFSET_PATH'); $base_path_uri = new lmbUri(rtrim($base_path, '/')); $base_path_uri->normalizePath(); $level = 1; while ($uri->getPathElement($level) == $base_path_uri->getPathElement($level) && $level < $base_path_uri->countPath()) { $level++; } return $level; }