xDimGG / node-steamapi

An object-oriented Steam API wrapper for Node.js developers.
https://www.npmjs.com/package/steamapi
177 stars 43 forks source link

[semantics][non-issue(?)] GetUserRecentGames: edge case on count #45

Closed WillsterJohnson closed 1 year ago

WillsterJohnson commented 1 year ago

Relevant: https://github.com/xDimGG/node-steamapi/commit/6447177c8db70744761fd6b670a86535f534d2dd

By checking count for truthiness, count=0 is excluded.

I realise that a user passing in count=0 is probably making a mistake rather than requesting no response, though semantically this check ought to be a null check rather than a truthy one. The effects are the same, as it appears Steam servers are also performing a truthy check (...&count=0 has the same response as an unspecified count); this is purely semantic.

const countInterpolation = count === null || count === undefined ? "" : `count=${count}`;
// ... interpolate the above constant / add the above expression as interpolation

or

const shouldInterpolateCount = (count ?? undefined) === undefined;
// ...
shouldInterpolateCount ? `count=${count}` : ""
xDimGG commented 1 year ago

Added a proper sanity check in 1137dec2359d6df7d9eba0bc03ca17a9b8fd8380. Thanks for bringing this to my attention