This commit is contained in:
Graham Campbell
2015-06-12 22:49:08 +01:00
parent 0aacc038c2
commit 615f9e0d75

View File

@@ -14,6 +14,7 @@ namespace CachetHQ\Cachet\Http\Controllers;
use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Incident;
use Illuminate\Support\Str;
use Roumen\Feed\Facades\Feed;
class AtomController extends AbstractController
@@ -30,7 +31,7 @@ class AtomController extends AbstractController
$feed = Feed::make();
$feed->title = Setting::get('app_name');
$feed->description = trans('cachet.feed');
$feed->link = $this->canonicalizeUrl(Setting::get('app_domain'));
$feed->link = Str::canonicalize(Setting::get('app_domain'));
$feed->setDateFormat('datetime');
@@ -52,27 +53,19 @@ class AtomController extends AbstractController
/**
* Adds an item to the feed.
*
* @param Roumen\Feed\Facades\Feed $feed
* @param \Roumen\Feed\Facades\Feed $feed
* @param \CachetHQ\Cachet\Models\Incident $incident
*
* @return void
*/
private function feedAddItem(&$feed, $incident)
{
$feed->add(
$incident->name,
Setting::get('app_name'),
$this->canonicalizeUrl(Setting::get('app_domain')).'#'.$incident->id,
Str::canonicalize(Setting::get('app_domain')).'#'.$incident->id,
$incident->created_at->toAtomString(),
$incident->message
);
}
/**
* Add a / at the end of an URL to in order to be W3C compliant
*
* @param string $url
*/
private function canonicalizeUrl($url)
{
return preg_replace('/([^\/])$/', '$1/', $url);
}
}