-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add support for parameters as Array #39
Add support for parameters as Array #39
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution!
I have reviewed it!
@@ -11,7 +11,13 @@ class JavaScript < Base | |||
var query = []; | |||
for (var param in params) if (Object.prototype.hasOwnProperty.call(params, param)) { | |||
if (keys.indexOf(param) === -1) { | |||
query.push(param + "=" + encodeURIComponent(params[param])); | |||
if (Array.isArray(params[param])) { | |||
for (var value of params[param] as Value[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove type assertion, since it's JavaScript. 🙏
for (var value of params[param] as Value[]) { | |
for (var value of params[param]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback. I have made the suggested changes.
@@ -7,14 +7,20 @@ module JSRailsRoutes | |||
module Language | |||
class TypeScript < JavaScript | |||
PROCESS_FUNC = <<~TYPESCRIPT | |||
type Value = string | number | |||
type Value = string | number | Value[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this instead, since we don't expect array of array?
type Value = string | number | Value[] | |
type Value = string | number | (string | number)[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback. I have made the suggested changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you!
https://edgeguides.rubyonrails.org/action_controller_overview.html#hash-and-array-parameters
This pull request introduces an enhancement to the js_rails_routes library by adding support for array parameters in URLs, aligning with the Ruby on Rails guideline for handling hash and array parameters.