Closed gc-victor closed 3 months ago
Thanks for that crystal clear bug report @gc-victor! I'm working on a fix!
@richarddavison if you didn't start it, I can work on it.
@gc-victor thanks but almost ready with a PR 🥇
I think this should cover it: https://github.com/awslabs/llrt/pull/327
Tries to get option from options arg first. Then if not found falls back to "resource" property. If resource property is is not Request
and has a toString
method (for example URL) that one is used. If it's a plain object, it's considered as an options object also. I think that should cover all cases, but please review if I missed something.
(Wow, these web APIs has two many alternatives on how to call them)
I have added a couple of minor comments. I didn't test it, but it looks good. In an ideal world, these APIs should be tested using wpt. Deno and other runtimes use it.
(Wow, these web APIs has two many alternatives on how to call them)
It is hard to be compliant with the specifications.
Reference: https://github.com/web-platform-tests/wpt
Agree. That's why we added support for expect so LLRT tests can run vitest with node and if both passes we're good!
Agree. That's why we added support for expect so LLRT tests can run vitest with node and if both passes we're good!
I didn't check that part. I have to take a look into it.
There is a issue in the
get_url_options
function. In the current implementation, if a user uses as an input a URL or Request object, there is a "Missing required URL" error.A fetch can receive a String, URL, or Request as an input, so when it is an object, it has to get the url string from the URL (href/toString()) or the Request objects.
https://github.com/awslabs/llrt/blob/a34b403d3b77277d86637462954ecce94fc96d7c/src/http/fetch.rs#L184
It should be something like this:
Once this is solved, there is another bug in this line:
https://github.com/awslabs/llrt/blob/a34b403d3b77277d86637462954ecce94fc96d7c/src/http/fetch.rs#L108
A mapping has to be done between the two objects.
In the MDN documentation, there is a link to an example of how it could work:
https://github.com/mdn/dom-examples/blob/6d7115ef281a5576d5cc53532380e845eb1adc07/fetch/fetch-with-init-then-request/index.html
Reference: https://developer.mozilla.org/en-US/docs/Web/API/fetch#resource https://github.com/awslabs/llrt/blob/a34b403d3b77277d86637462954ecce94fc96d7c/src/http/fetch.rs