Skip to content

Commit

Permalink
Fix: upload reachability test should accept empty preflight response (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wenboyu2 authored Jan 12, 2018
1 parent 7d0746d commit 5e7a39a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/api/uploads/UploadReachability.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,11 @@ class UploadsReachability {
* @return {string}
*/
handlePreflightResponse(response?: Object) {
if (!response) {
if (!response || !response.upload_url) {
return DEFAULT_HOSTNAME_UPLOAD;
}

const { upload_url } = response;

const splitUrl = upload_url.split('/');
const splitUrl = response.upload_url.split('/');
return `${splitUrl[0]}//${splitUrl[2]}`;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/api/uploads/__tests__/UploadsReachability-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('api/UploadsReachability', () => {
describe('handlePreflightResponse()', () => {
withData(
[
[{random: 1}, DEFAULT_HOSTNAME_UPLOAD],
[undefined, DEFAULT_HOSTNAME_UPLOAD],
[null, DEFAULT_HOSTNAME_UPLOAD],
[{ upload_url: 'http://random.com/hello123' }, 'http://random.com']
Expand Down

0 comments on commit 5e7a39a

Please sign in to comment.