-
Notifications
You must be signed in to change notification settings - Fork 16
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 jsform #58
Add jsform #58
Conversation
how about: func newFormData*(): FormData =
when defined(nodejs):
asm """
var tmp = require("form-data")
`result` = new tmp()
"""
else:
asm "`result` = new FormData()"
...
runnableExamples:
from strutils import startsWith
if defined(fusionJsFormdataTests):
let data: FormData = newFormData()
when defined(nodejs):
data.add "key0", "value0"
data.add "key1", "value1"
var ret: cstring
asm """`ret` = `data`.getHeaders()["content-type"]"""
doAssert ($ret).startsWith """multipart/form-data; boundary=""", $ret
else:
data["key0".cstring] = "value0".cstring
data.add("key1".cstring, "value1".cstring)
data.delete("key1".cstring)
doAssert data.hasKey("key0".cstring)
doAssert data["key0".cstring] == "value0".cstring
tested with:
note: EDITignore this comment, looks like |
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.
LGTM after addressing the last comment
Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
See nim-lang/Nim#16339 (comment) and nim-lang/Nim#16339 (comment) and #57 (comment) and #56 (comment) and #55 (comment)
and #58 (comment)