Skip to content

Updated Query Param Parsers to Handle Repeated Keys#66

Merged
jpodwys merged 6 commits intojpodwys:masterfrom
chriswsh:master
Mar 14, 2020
Merged

Updated Query Param Parsers to Handle Repeated Keys#66
jpodwys merged 6 commits intojpodwys:masterfrom
chriswsh:master

Conversation

@chriswsh
Copy link
Copy Markdown
Contributor

There didn't seem to be a way to reliably trigger specific paths in getHeaderOptions, and the most recent code for superagent mentions that Request.qsRaw is deprecated, so behavioral testing didn't seem appropriate.

Instead, I added a new test file to verify functionality at the unit level.

(I also continued to target ES5 for the code itself)

Comment thread utils.js Outdated
obj[kvString[0]] = [obj[kvString[0]], kvString[1]];
} else {
obj[kvString[0]] = kvString[1];
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you, this addition looks great! Seeing as the code added to both arrayToObj and stringToObj is identical, would you mind moving them into a separate method? Once that's in place, I'll be happy to merge.

Copy link
Copy Markdown
Contributor Author

@chriswsh chriswsh Mar 14, 2020

Choose a reason for hiding this comment

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

Here it is. I prefer the functional programming paradigm, so I'm a bit leery of extracting into a function that performs mutation by reference. But Object.assign wasn't implemented in ES5 and I doubt you'd appreciate me bloating your library w/ a polyfill or lodash.

I did write the function so it has a return value and added a warning in the declaration comments to mitigate--will that work?

@jpodwys jpodwys merged commit 1f46869 into jpodwys:master Mar 14, 2020
@jpodwys
Copy link
Copy Markdown
Owner

jpodwys commented Mar 14, 2020

Thank you for the PR and the edit! Published to NPM as 3.1.1.

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