Skip to content

Commit

Permalink
Sanity-check response from /thirdparty/protocols
Browse files Browse the repository at this point in the history
Check that /thirdparty/protocols gives us an object (rather than a string, for
instance). I saw a test explode, apparently because it gave us a string. Which
is odd, but in general we ought to be sanity-checking the things coming back
from the server.
  • Loading branch information
richvdh committed Jul 5, 2017
1 parent 6ae714f commit 598d40b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/base-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,15 @@ MatrixBaseApis.prototype.getThirdpartyProtocols = function() {
return this._http.authedRequestWithPrefix(
undefined, "GET", "/thirdparty/protocols", undefined, undefined,
httpApi.PREFIX_UNSTABLE,
);
).then((response) => {
// sanity check
if (!response || typeof(response) !== 'object') {
throw new Error(
`/thirdparty/protocols did not return an object: ${response}`,
);
}
return response;
});
};

/**
Expand Down

0 comments on commit 598d40b

Please sign in to comment.