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

About the updated form array in v1.7.5 #4629

Closed
xuerbujia opened this issue Feb 7, 2025 · 7 comments · Fixed by #4633 · May be fixed by #4638
Closed

About the updated form array in v1.7.5 #4629

xuerbujia opened this issue Feb 7, 2025 · 7 comments · Fixed by #4633 · May be fixed by #4638

Comments

@xuerbujia
Copy link
Contributor

xuerbujia commented Feb 7, 2025

When I Declaer

var v struct {
Codes []string form:"Codes"
}
If a code is comma separated like aaa,bbb,ccc. When I enter parameter ? codes=aaa,bbb,ccc&codes=ccc,ddd,eeeIt is normal but when I enter only one ? codes=aaa,bbb,ccc And it blew up.
So I think we should use the tag to turn this comma-separated array parsing on or off
Image

Image

@xuerbujia
Copy link
Contributor Author

I can post a PR if it have to

@kevwan
Copy link
Contributor

kevwan commented Feb 7, 2025

on codes=aaa,bbb,ccc, it will be splitted as ["aaa", "bbb", "ccc"].

This is not what you want?

@xuerbujia
Copy link
Contributor Author

xuerbujia commented Feb 7, 2025

on codes=aaa,bbb,ccc, it will be splitted as ["aaa", "bbb", "ccc"].

This is not what you want?

"aaa,bbb,ccc" is a key.My param is a array of the key, and it gets wrong split when I input in only one

@kevwan
Copy link
Contributor

kevwan commented Feb 7, 2025

check it out here: https://stackoverflow.com/a/9547490

@xuerbujia
Copy link
Contributor Author

Most of the discussion in this link is? a[]=1&a[]=2 or? a=1&a=2 .These two are fine as the default enable mode but the comma separation has the above bad case. I think there needs to be a way for the user to choose to enable or disable the one through the tag.

@xuerbujia
Copy link
Contributor Author

code="aaa,bbb,ccc" is a key.
On the same API:
/path?codes=aaa,bbb,ccc&codes=ccc,ddd,eee --> []string{"aaa,bbb,ccc","ccc,ddd,eee"} Fine
path?code=aaa,bbb,ccc --> []string{"aaa","bbb","ccc"} bad. Because in this api the code(aaa,bbb,ccc) is a key.

@kevwan
Copy link
Contributor

kevwan commented Feb 8, 2025

I can post a PR if it have to

OK, thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants