/** * Test the isSSL method. * * @return void * * @since 11.1 * @covers JUri::isSSL */ public function testIsSSL() { $this->object->parse('https://*****:*****@www.example.com:80/path/file.html?var=value#fragment'); $this->assertThat($this->object->isSSL(), $this->equalTo(true)); $this->object->parse('http://*****:*****@www.example.com:80/path/file.html?var=value#fragment'); $this->assertThat($this->object->isSSL(), $this->equalTo(false)); }
/** * getHost. * * @return string */ public static function getHost() { $baseurl = JUri::root(); $uri = new JUri(); if ($uri->parse($baseurl)) { $host = $uri->toString(array('scheme', 'host', 'port')); return $host; } return null; }
/** * Test hardening of JUri::isInternal against non internal links * * @return void * * @covers JUri::isInternal */ public function testsefurl() { $this->object->parse('/login'); $this->assertFalse($this->object->isInternal('/login')); }
/** * Give a relative path, return path with host. * * @param string $path A system path. * * @return string Path with host added. */ public static function pathAddHost($path) { if (!$path) { return ''; } // Build path $uri = new \JUri($path); if ($uri->getHost()) { return $path; } $uri->parse(\JUri::root()); $root_path = $uri->getPath(); if (strpos($path, $root_path) === 0) { $num = Utf8String::strlen($root_path); $path = Utf8String::substr($path, $num); } $uri->setPath($uri->getPath() . $path); $uri->setScheme('http'); $uri->setQuery(null); return $uri->toString(); }