Fix bug in uploading diff file from new review request UI.
Review Request #12688 — Created Oct. 18, 2022 and submitted — Latest diff uploaded
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 tonull
instead of an empty string. Then when sending a request to validate the diff,
ourValidateDiffModel
would build the request URL by prepending the
localSitePrefix
to aapi/validation/diffs/
URI. So when the
localSitePrefix
isnull
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 isnull
when building the URL. This is consistent with
the way we handle thelocalSitePrefix
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.