/** * Private method for building the URL object * * @return \r8\URL */ private function buildURL() { $url = new \r8\URL(); // Get the url Scheme from the server protocol if (self::hasKey($this->server, "SERVER_PROTOCOL")) { $url->setScheme(strtolower(strstr($this->server['SERVER_PROTOCOL'], "/", TRUE))); } // Pull the server host, if it is set if (self::hasKey($this->server, 'HTTP_HOST')) { $url->setHost($this->server['HTTP_HOST']); } else { if (self::hasKey($this->server, "SERVER_ADDR")) { $url->setHost($this->server['SERVER_ADDR']); } } // Pull the port if (self::hasKey($this->server, "SERVER_PORT")) { $url->setPort((int) $this->server['SERVER_PORT']); } // The path and file name if (self::hasKey($this->server, 'SCRIPT_NAME')) { $url->setPath($this->server['SCRIPT_NAME']); } // The faux directories if (self::hasKey($this->server, 'PATH_INFO')) { $url->setFauxDir(\r8\str\head($this->server['PATH_INFO'], "/")); } // Finally, pull the the URL query if (self::hasKey($this->server, 'QUERY_STRING')) { $url->setQuery($this->server['QUERY_STRING']); } return $url; }
public function testCopyURL() { $url = new \r8\URL(); $this->assertSame($url, $url->copyURL(new \r8\URL())); $this->assertNull($url->getURL()); $source = new \r8\URL("http://*****:*****@test.example.com:40/path/to/file.php?var=value#frag"); $source->setFauxDir("/test/faux/dirs"); $this->assertSame($url, $url->copyURL($source)); $this->assertSame("http://*****:*****@test.example.com:40/path/to/file.php/test/faux/dirs?var=value#frag", $url->getURL()); }