2 ms·
It uses XML, which requires a library for browser JavaScript (EDIT: not true, see comment below), when filesystem operations don't really need to be more compli
by anderspitman 4y ago
It uses XML, which requires a library for browser JavaScript (EDIT: not true, see comment below), when filesystem operations don't really need to be more complicated than vanilla fetch requests. Also uses special HTTP methods, which isn't ideal. I've heard people say that various implementations are often incompatible with each other in some ways. I'm not sure how big of a problem this actually is in practice, but see for example this readme[0] which explicitly says the library doesn't seek to be compatible with RFCs, but rather with implementations in the wild. That's a red flag to me. See also [1].
Trying to use a subset is an interesting idea, but the technical problem being solved is simple enough that I don't see a strong reason not to just greenfield it and make a bunch of nice improvements along with the critical ones.
[0]: https://github.com/perry-mitchell/webdav-client#about https://github.com/perry-mitchell/webdav-client#about
[1]: https://news.ycombinator.com/item?id=10213657 https://news.ycombinator.com/item?id=10213657
- hunterb123 4y ago> It uses XML, which requires a library for browser JavaScript, What? XMLHTTPRequest (XHR) People forget XML parsing is baked into JS as is XPath But I do agree with your premise otherwise.
- anderspitman 4y agoHa. Honestly, you're totally right. I've used XHR for years but never actually for XML. When looking at WebDAV in the past I couldn't find a way to serialize/deserialize XML the same way you can with JSON (is there a way?), but I didn't realize XHR handles that natively. TIL, thanks.
- easrng 4y agoYou can use a DOMParser to parse XML (or HTML) from a string. const doc = new DOMParser().parseFromString('<xml><tag attr="value" /></xml>', "text/xml"); doc.querySelector("tag").getAttribute("attr") // returns "value"
- anderspitman 4y agoAwesome, thanks! I could have sworn I looked into this and didn't find a way in vanilla JS, but definitely looks like I was wrong.