diff --git a/components/collector/src/source_collectors/source_collector.py b/components/collector/src/source_collectors/source_collector.py index 2a42a40a05..25459c0e8b 100644 --- a/components/collector/src/source_collectors/source_collector.py +++ b/components/collector/src/source_collectors/source_collector.py @@ -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.""" @@ -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]: diff --git a/components/collector/tests/source_collectors/test_jira.py b/components/collector/tests/source_collectors/test_jira.py index 8dcdb704a0..afe31f2136 100644 --- a/components/collector/tests/source_collectors/test_jira.py +++ b/components/collector/tests/source_collectors/test_jira.py @@ -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 = [] diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 971df4a8a3..20187227b9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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