public function testFullRelativePath()
 {
     $this->assertEquals("dir1/common.css", AmberNetworkUtils::full_relative_path("dir1", "common.css"));
     $this->assertEquals("dir1/bananas/common.css", AmberNetworkUtils::full_relative_path("dir1", "bananas/common.css"));
     $this->assertEquals("dir1/common.css", AmberNetworkUtils::full_relative_path("dir1", "bananas/../common.css"));
     $this->assertEquals("dir1/common.css", AmberNetworkUtils::full_relative_path("dir1/dir2", "../common.css"));
     $this->assertEquals("_v_1.0.32/personal/common.css", AmberNetworkUtils::full_relative_path("_v_1.0.32/personal/photo", "../common.css"));
     $this->assertEquals("/persian/news/newsitem/article/typo3conf/ext/kj_imagelightbox2/res/lightbox2.04/js/prototype.js", AmberNetworkUtils::full_relative_path("/persian/news/newsitem/article", "typo3conf/ext/kj_imagelightbox2/res/lightbox2.04/js/prototype.js"));
 }
 /**
  * Given a page URL and a list of assets referenced from that page, return an array list of absolute URIs
  * to each of the assets keyed by the path used to reference it. 
  * @param $page_url
  * @param $assets
  * @param $html_base string with the contents of the <base> tag from the page, if exists
  */
 public function expand_asset_references($page_url, $assets, $html_base = "")
 {
     $result = array();
     $p = parse_url($page_url);
     if ($p) {
         $path_array = explode('/', isset($p['path']) ? $p['path'] : "");
         array_pop($path_array);
         $server = $p['scheme'] . "://" . $p['host'] . (isset($p['port']) ? ":" . $p['port'] : '');
         $page_url = $server . join('/', $path_array);
         foreach ($assets as $asset) {
             $asset_copy = $asset;
             if (strpos($asset, "//") === 0) {
                 /* Ensure that every URL has a scheme. Must be done before running parse_url due to bug in PHP < 5.4.7 */
                 /* Workaround for bug in parse_url: http://us2.php.net/parse_url#refsect1-function.parse-url-changelog */
                 $asset_copy = "{$p['scheme']}:{$asset_copy}";
             }
             /* Skip data assets that don't reference external resources */
             if (strpos($asset, ";base64") !== FALSE) {
                 continue;
             }
             $parsed_asset_copy = parse_url($asset_copy);
             $asset_path = $asset_copy;
             if ($parsed_asset_copy) {
                 if (!isset($parsed_asset_copy['host'])) {
                     if (!($asset_path && $asset_path[0] == '/')) {
                         /* Relative path */
                         if ($html_base) {
                             $result[$asset]['url'] = $html_base . $asset_path;
                             continue;
                         } else {
                             $asset_path = AmberNetworkUtils::full_relative_path(join('/', $path_array), $asset_path);
                         }
                     }
                     $asset_path = preg_replace("/^\\//", "", $asset_path);
                     /* Remove leading '/' */
                     $asset_path = join('/', array($server, $asset_path));
                 }
                 $result[$asset]['url'] = $asset_path;
             }
         }
     }
     return $result;
 }