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

fix for form parameter names with [brackets] #36

Merged
merged 1 commit into from
Aug 29, 2016
Merged

fix for form parameter names with [brackets] #36

merged 1 commit into from
Aug 29, 2016

Conversation

cgrayson
Copy link
Contributor

Fix for #8.

I didn't find a way to keep _.set() from treating brackets in the key as part of the path, and turning them into sub-objects.

# _.set would treat a key string with brackets as object path notation (foo[bar] -> foo.bar)
content[key] = value
else
_.set(content, key, value)
Copy link
Contributor

Choose a reason for hiding this comment

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

As we discussed, we could do away with flat.flatten() and _.set() if normalize() were a recursive function.

@cgrayson
Copy link
Contributor Author

Stumbled upon this on the way to recursion… :-) Added a test to json-spec that I think covers what we discussed; let me know if not. (That new test would indeed have failed with the previous commit's code.)

@@ -22,6 +22,6 @@ module.exports = normalize = (obj, toAscii = false) ->
else
null

_.set(content, key, value)
content[key] = value
Copy link
Contributor

@alexkwolfe alexkwolfe Aug 29, 2016

Choose a reason for hiding this comment

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

If you wanted, the content[key] assignment could go on line 15:

content[key] = 
  if value?.valid == false
    ...
  else 
    ...

@alexkwolfe
Copy link
Contributor

Other than that comment, LGTM. Glad that worked. 👍

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.

None yet

2 participants