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

Implement GET query params #33

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

niklasva82
Copy link
Member

Resolves #32

Copy link
Member

@richardolsson richardolsson left a comment

Choose a reason for hiding this comment

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

Really nice work! I have a few comments below. I'm not sure changes are required, but I think so? Let me know what you think.

index.js Show resolved Hide resolved
index.js Outdated
}
query = Object.keys(queryObject)
// Filter any keys with values that evaluate to false
.filter(key => !!queryObject[key])
Copy link
Member

Choose a reason for hiding this comment

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

Is this desirable? Could there not be a case where sending a zero makes sense and should be possible? If I'm not mistaken, a query-object like { max_length: 0 } will be a no-op. Is that good? I'm not sure!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes you're right! I will filter on !== false instead.

index.js Outdated
if(queryObject[key] === true) {
return key;
} else {
return key + '=' + queryObject[key];
Copy link
Member

Choose a reason for hiding this comment

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

How does it deal with escaping/URL encoding? What happens if you pass an object like { foo: "bar&baz" }?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, this could present problems, I will add url encoding.

…rt that invalid query argument location throws error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GET query parameters
2 participants