Skip to content

Commit

Permalink
[GithubIssueBridge] Don't return error messages in detectParameters()
Browse files Browse the repository at this point in the history
detectParameters() is called in a loop for all bridges on a URL, thus
if a bridge returns an error message, the output messages get mixed
up and all detect operations fail.

This seems to be a limitation of the detect function for now.
  • Loading branch information
logmanoriginal committed Jun 13, 2019
1 parent 2559dbb commit 6d6d603
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions bridges/GithubIssueBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,24 +242,8 @@ public function collectData(){

public function detectParameters($url) {

$help = <<<EOD
Usage:
For project issues the URL must include /<user>/<project>
For issue comments the URL must include /<user>/<project>/issues/<issue-number>
Examples:
- https://github.com/rss-bridge/rss-bridge
- https://github.com/rss-bridge/rss-bridge/issues/1
Issue comments for project issues are enabled if the URL points to issues
https://github.com/rss-bridge/rss-bridge/issues
EOD;

if(filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) === false
|| strpos($url, self::URI) !== 0) {
returnClientError('Invalid URL' . $help);
return null;
}

Expand All @@ -273,11 +257,7 @@ public function detectParameters($url) {
} break;
case 3: { // Project issues with issue comments
if($path_segments[2] !== 'issues') {
returnClientError('Invalid path. Expected "/issues/", found "/'
. $path_segments[2]
. '/"'
. $help
);
return null;
}
list($user, $project) = $path_segments;
$show_comments = 'on';
Expand All @@ -286,7 +266,7 @@ public function detectParameters($url) {
list($user, $project, /* issues */, $issue) = $path_segments;
} break;
default: {
returnClientError('Invalid path.' . $help);
return null;
}
}

Expand Down

0 comments on commit 6d6d603

Please sign in to comment.