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

feat: Update getBuilds filter param to support array values #149

Merged
merged 2 commits into from
Oct 28, 2019

Conversation

timhaines
Copy link
Contributor

Percy's getBuilds API endpoint now supports a few new params: branch, state, and shas. shas is an array of values.

This PR adds support to getBuilds for handling filter params with array values.

@timhaines timhaines changed the title Update getBuilds filter param to support array values feat: Update getBuilds filter param to support array values Oct 28, 2019
Copy link
Contributor

@Robdel12 Robdel12 left a comment

Choose a reason for hiding this comment

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

One small comment. LGTM 😃 🏁

src/main.js Outdated
if (Array.isArray(filter[key])) {
// If filter value is an array, match Percy API's format expectations of:
// filter[key][]=value1&filter[key][]=value2
return filter[key].map(array_value => 'filter[' + key + '][]=' + array_value).join('&');
Copy link
Contributor

Choose a reason for hiding this comment

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

A little picky, but we could interpolate rather than concat:

return filter[key].map(array_value => `filter[${key}][]=${array_value}`).join('&');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pickiness of the good kind. Will update and merge.

@timhaines timhaines merged commit f596999 into master Oct 28, 2019
@timhaines timhaines deleted the th/improve-filter-support branch October 28, 2019 17:21
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.

2 participants