Ejemplo n.º 1
0
 /**
  * Make relative url absolute
  * @param string $url image url
  * @param string $quote single or double quote
  * @param string $cssFile absolute css file path
  * @return string
  */
 public function absolutizeUrl($url, $quote, $cssFile)
 {
     // is already absolute
     if (preg_match('/^([a-z]+:\\/)?\\//', $url)) {
         return $url;
     }
     $cssFile = \WebLoader\Path::normalize($cssFile);
     // inside document root
     if (strncmp($cssFile, $this->docRoot, strlen($this->docRoot)) === 0) {
         $path = $this->basePath . substr(dirname($cssFile), strlen($this->docRoot)) . DIRECTORY_SEPARATOR . $url;
     } else {
         // outside document root we don't know
         return $url;
     }
     $path = $this->cannonicalizePath($path);
     return $quote === '"' ? addslashes($path) : $path;
 }
Ejemplo n.º 2
0
 private function assertEqualPaths($expected, $actual)
 {
     $actual = (array) $actual;
     foreach ((array) $expected as $key => $path) {
         $this->assertTrue(isset($actual[$key]));
         $this->assertEquals(\WebLoader\Path::normalize($path), \WebLoader\Path::normalize($actual[$key]));
     }
 }
Ejemplo n.º 3
0
 public function testNormalize()
 {
     $normalized = Path::normalize('/path/to//project//that/contains/0/in/it');
     $this->assertEquals('/path/to/project/that/contains/0/in/it', $normalized);
 }