public function testAddScheme() { $this->assertEquals('http://example.org', Html::addScheme('example.org')); $this->assertEquals('http://example.org', Html::addScheme('http://example.org')); $this->assertEquals('https://example.org', Html::addScheme('https://example.org')); $this->assertEquals('mailto:bob@bolt.cm', Html::addScheme('mailto:bob@bolt.cm')); }
/** * Create an HTML link to a given URL or contenttype/slug pair. * * @param string $location * @param string $label * * @return string */ public function link($location, $label = '[link]') { if ((string) $location === '') { return ''; } if (Html::isURL($location)) { $location = Html::addScheme($location); } elseif ($record = $this->app['storage']->getContent($location)) { $location = $record->link(); } return sprintf('<a href="%s">%s</a>', $location, $label); }