public function testValidateUrl() { $this->assertTrue(ae_Validate::urlSloppy('http://sebadorn.de')); $this->assertTrue(ae_Validate::urlSloppy('https://sebadorn.de')); $this->assertTrue(ae_Validate::urlSloppy('ftp://sebadorn.de')); $this->assertTrue(ae_Validate::urlSloppy('ftps://sebadorn.de')); $this->assertTrue(ae_Validate::urlSloppy('https://sebädörnß.de')); $this->assertTrue(ae_Validate::urlSloppy('https://example.com#anchor')); $this->assertTrue(ae_Validate::urlSloppy('https://example.com?foo=bar&lorem%20ipsum')); $this->assertFalse(ae_Validate::urlSloppy('http://with whitespace')); $this->assertFalse(ae_Validate::urlSloppy('noprotocoll.foo')); $this->assertFalse(ae_Validate::urlSloppy(NULL)); }
/** * Set comment author URL. * @param {string} $url The URL. Either a valid URL or an empty string. * @throws {Exception} If $url is neither empty nor valid. */ public function setAuthorUrl($url) { $url = trim($url); if ($url !== '' && !ae_Validate::urlSloppy($url)) { $msg = sprintf('[%s] Not a valid URL: %s', get_class(), htmlspecialchars($url)); throw new Exception($msg); } $this->authorUrl = $url; }