Skip to content

Commit

Permalink
Prevent double slashes in URLs to Jira issues. Fixes #817. (#820)
Browse files Browse the repository at this point in the history
* Prevent double slashes in URLs to Jira issues. Fixes #817.
  • Loading branch information
fniessink authored Nov 26, 2019
1 parent e59b12b commit 6ef1ff9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ def get(self) -> Measurement:
def _landing_url(self, responses: Responses) -> URL: # pylint: disable=unused-argument
"""Return the user supplied landing url parameter if there is one, otherwise translate the url parameter into
a default landing url."""
if landing_url := cast(str, self.__parameters.get("landing_url", "")).strip("/"):
if landing_url := cast(str, self.__parameters.get("landing_url", "")).rstrip("/"):
return URL(landing_url)
url = cast(str, self.__parameters.get("url", "")).strip("/")
url = cast(str, self.__parameters.get("url", "")).rstrip("/")
return URL(url[:-(len("xml"))] + "html" if url.endswith(".xml") else url)

def _api_url(self) -> URL:
"""Translate the url parameter into the API url."""
return URL(cast(str, self.__parameters.get("url", "")).strip("/"))
return URL(cast(str, self.__parameters.get("url", "")).rstrip("/"))

def _parameter(self, parameter_key: str, quote: bool = False) -> Union[str, List[str]]:
"""Return the parameter value."""
Expand All @@ -79,6 +79,8 @@ def quote_if_needed(parameter_value):
value = self.__parameters.get(parameter_key, default_value)
if api_values := parameter_info.get("api_values"):
value = api_values.get(value, value) if isinstance(value, str) else [api_values.get(v, v) for v in value]
if parameter_key.endswith("url"):
value = cast(str, value).rstrip("/")
return quote_if_needed(value) if isinstance(value, str) else [quote_if_needed(v) for v in value]

def __safely_get_source_responses(self) -> Tuple[Responses, URL, ErrorMessage]:
Expand Down
2 changes: 1 addition & 1 deletion components/collector/tests/source_collectors/test_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def setUp(self):
source_id=dict(
type="jira",
parameters=dict(
url="https://jira", jql="query", story_points_field="field",
url="https://jira/", jql="query", story_points_field="field",
manual_test_execution_frequency_field="desired_test_frequency",
manual_test_duration_field="field")))
self.fields_json = []
Expand Down
3 changes: 2 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed

- Users would not be notified of an expired session when trying to delete something while their session was expired. Fixes [#813](https://github.com/ICTU/quality-time/issues/813).

- Prevent double slashes in URLs to Jira issues. Fixes [#817](https://github.com/ICTU/quality-time/issues/817).

## [0.20.0] - [2019-11-23]

### Fixed
Expand Down

0 comments on commit 6ef1ff9

Please sign in to comment.