mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-19 06:42:14 +02:00
fix(FeedExpander): if parse fails, include offending url in exception message (#3938)
Also some refactors
This commit is contained in:
@@ -4,14 +4,14 @@ class DetectAction implements ActionInterface
|
||||
{
|
||||
public function execute(Request $request)
|
||||
{
|
||||
$targetURL = $request->get('url');
|
||||
$url = $request->get('url');
|
||||
$format = $request->get('format');
|
||||
|
||||
if (!$targetURL) {
|
||||
throw new \Exception('You must specify a url!');
|
||||
if (!$url) {
|
||||
return new Response(render(__DIR__ . '/../templates/error.html.php', ['message' => 'You must specify a url']));
|
||||
}
|
||||
if (!$format) {
|
||||
throw new \Exception('You must specify a format!');
|
||||
return new Response(render(__DIR__ . '/../templates/error.html.php', ['message' => 'You must specify a format']));
|
||||
}
|
||||
|
||||
$bridgeFactory = new BridgeFactory();
|
||||
@@ -23,19 +23,23 @@ class DetectAction implements ActionInterface
|
||||
|
||||
$bridge = $bridgeFactory->create($bridgeClassName);
|
||||
|
||||
$bridgeParams = $bridge->detectParameters($targetURL);
|
||||
$bridgeParams = $bridge->detectParameters($url);
|
||||
|
||||
if (is_null($bridgeParams)) {
|
||||
if (!$bridgeParams) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$bridgeParams['bridge'] = $bridgeClassName;
|
||||
$bridgeParams['format'] = $format;
|
||||
|
||||
$url = '?action=display&' . http_build_query($bridgeParams);
|
||||
return new Response('', 301, ['location' => $url]);
|
||||
$query = [
|
||||
'action' => 'display',
|
||||
'bridge' => $bridgeClassName,
|
||||
'format' => $format,
|
||||
];
|
||||
$query = array_merge($query, $bridgeParams);
|
||||
return new Response('', 301, ['location' => '?' . http_build_query($query)]);
|
||||
}
|
||||
|
||||
throw new \Exception('No bridge found for given URL: ' . $targetURL);
|
||||
return new Response(render(__DIR__ . '/../templates/error.html.php', [
|
||||
'message' => 'No bridge found for given URL: ' . $url,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
@@ -9,10 +9,10 @@ class FindfeedAction implements ActionInterface
|
||||
{
|
||||
public function execute(Request $request)
|
||||
{
|
||||
$targetURL = $request->get('url');
|
||||
$url = $request->get('url');
|
||||
$format = $request->get('format');
|
||||
|
||||
if (!$targetURL) {
|
||||
if (!$url) {
|
||||
return new Response('You must specify a url', 400);
|
||||
}
|
||||
if (!$format) {
|
||||
@@ -29,7 +29,7 @@ class FindfeedAction implements ActionInterface
|
||||
|
||||
$bridge = $bridgeFactory->create($bridgeClassName);
|
||||
|
||||
$bridgeParams = $bridge->detectParameters($targetURL);
|
||||
$bridgeParams = $bridge->detectParameters($url);
|
||||
|
||||
if ($bridgeParams === null) {
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user