Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some broken code from collection.get #21

Merged
merged 1 commit into from
Nov 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions lib/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,6 @@ var factory = module.exports = function (request) {

if (query && typeof query === 'object') {
Copy link
Collaborator Author

@grdryn grdryn Sep 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this PR is correct and accepted, the only thing left in this condition is to overwrite requestObject.endpoint. If I'm correct, before it's overwritten here, it would be something like pods/[object Object], and this would overwrite it to pods. I think this is a case that should be handled by the getPath function itself, rather than needing to happen after it in certain circumstances, since the /[object Object] part is likely never desirable. What do you think?

I think making the following change on line 11 would achieve this:

- return each !== null && typeof each !== 'undefined';
+ return typeof each !== 'object' && typeof each !== 'undefined';

In the above replacement, the initial null check would no longer be needed, since typeof null === 'object'.

If you'd like, I can make that change in this PR (or in a separate one?)?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also just move that initial definition of requestObject.endpoint down into an } else { clause around line 167, so it isn't executed for the case where query is an object.

requestObject.endpoint = getPath(collection);

var qs = [];
Object.keys(query, function (key, value) {
qs.push(key + ':' + value);
});

requestObject.qs = { q: qs.join(';') };
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my testing you'd want to have requestObject.qs = query; here so that you can pass parameters like labelSelector, etc. through to the underlying endpoint.


async.until(function () {
Expand Down