fix: Redirect should have correct location header [DHIS2-18185] (2.41) #20067
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
When a redirect is returned, the URL is having a
/
stripped out when it shouldn't.E.g.
http://localhost:8080/api/apps/line-listing/
is being returned ashttp:/localhost:8080/api/apps/line-listing/
Cause
When the forward slash cleaning is done, it is removing an extra slash from
http://
tohttp:/
Because there are no guarantees about the strings and formatting being used currently, it is required to manually add
/
in several places to make sure to hopefully end up with a correct URL.Fix
Extract the base url first & remove any trailing slash from it, so we know that whatever string is added afterwards, it should be ok to clean.
Created a util method as this kind of pattern is used in multiple places (these places have also been updated as a matter of safety). This should help keep uniformity and reduce issues.
Testing
Automated
E2E test added
Unit tests added for new util method to help ensure correct URL format is sent.
Manual
Manually tested locally