dom96 / jester

A sinatra-like web framework for Nim.
MIT License
1.56k stars 120 forks source link

formData identical keys #310

Open noirscape opened 1 year ago

noirscape commented 1 year ago

Firstly, please correct me if I'm making any mistakes, but I don't think I am.

It is possible to have multiple entries with the same formData name - this is how, for example, clients send over file uploads that accept multiple files (in my example, I've written a PWA that tries to handle multiple files as a share target serverside). Unfortunately, it is deprecated to have a Table with duplicate keys (the add procedure is even being deprecated in favor of just doing []= assignments) and the allValues() procedure doesn't work with the OrderedTable that jester uses.

This means it's currently impossible to actually retrieve multiple entries from a table unless you manually iterate over pairs or values and manually check the key on the former/read out the fields table on the latter.

One possible solution could be to redefine the MultiData object to be an OrderedTable[string, seq[tuple[fields: StringTableRef, body: string]]] instead and append to the sequence instead, but this would probably hard break existing applications.