Fix bug in uploading diff file from new review request UI.

Review Request #12688 — Created Oct. 18, 2022 and submitted — Latest diff uploaded

Information

Review Board
release-5.0.x

Reviewers

A bug was discovered on the New Review Request page where using the
repositories search bar to filter the repositories and then selecting one would
break uploading diff files. Instead of being redirected to the review request
draft page after uploading a diff, the page would not redirect and the uploader
would just display a loading spinner. This happens because using the search bar
causes the repositories' localSitePrefix attribute to be set to null
instead of an empty string. Then when sending a request to validate the diff,
our ValidateDiffModel would build the request URL by prepending the
localSitePrefix to a api/validation/diffs/ URI. So when the
localSitePrefix is null this would result in a request being made to the
nullapi/validation/diffs/ URL, which does not exist.

This change fixes this by making sure the localSitePrefix is replaced with
an empty string if it is null when building the URL. This is consistent with
the way we handle the localSitePrefix for URL building in our other
Javascript models.

  • Manually tested uploading diff files with and without using the search bar
    to filter the repositories.
  • Added a JS unit test for this and ran all JS unit tests.

Commits

Files