arcgis-rest-js icon indicating copy to clipboard operation
arcgis-rest-js copied to clipboard

`isItemSharedWithGroup` returns `undefined` instead of false.

Open drewdaemon opened this issue 4 years ago • 2 comments

The return statement in isItemSharedWithGroup is incorrectly nested in an if block. This one flies under the radar because undefined is falsy, but it's a bug nonetheless.

function isItemSharedWithGroup(requestOptions) {
  var searchOpts = {
    q: "id: " + requestOptions.id + " AND group: " + requestOptions.groupId,
    start: 1,
    num: 10,
    sortField: "title",
    authentication: requestOptions.authentication,
    httpMethod: "POST"
  };
  return Object(_items_search__WEBPACK_IMPORTED_MODULE_7__["searchItems"])(searchOpts).then(function (searchResponse) {
    var result = false;

    if (searchResponse.total > 0) {
      result = searchResponse.results.some(function (itm) {
        return itm.id === requestOptions.id;
      });
      return result; // SHOULD BE OUTSIDE THE IF BLOCK
    }
  });
}

drewdaemon avatar Mar 03 '20 18:03 drewdaemon

nice catch. can you open a PR 🙏?

jgravois avatar Mar 03 '20 18:03 jgravois

Sure

drewdaemon avatar Mar 04 '20 13:03 drewdaemon