dom111 / webdav-js

A simple WebDAV client written in JS for use as a bookmarklet, or integration into a web server.
MIT License
85 stars 17 forks source link

Detect if the current URL has a WebDAV share #129

Open stokito opened 1 year ago

stokito commented 1 year ago

Currently if I'm on a page that doesn't have a WebDAV share and executing the bookmarklet then it's executed but as result I have a broken page.

It's fine, but maybe we can change order and first check OPTIONS and only then render the UI. And if the URL doesn't have a DAV header then gracefully say it to a user.

I'm going to implement this for the browser extension #128 but this may be done by the webdav-js itself.

stokito commented 1 year ago

Also currently the webdav-js loading automatiaclly and renders directory folder. So if the script is added to <head> then loading happening no matter of what. I need to trigger the loading manualy. The problem is that when I using it from the WebDAV usercript I can't use @require but instead I need to manually create a <script> tag with the library. While we can @require JS files we need to load manually CSS files. So first I need to load CSS and only then load the JS

stokito commented 1 year ago

Ok so here I implemented the loader myself:

https://github.com/WebDAVDevs/webdav-browser-extension/blob/master/loadWebdavJs.js

The OPTIONS can't be used because the DAV header is hidden when making a request from JS. So instead I called a PROPFIND Depth:0 and then checking a body. The entire webdav-js script I wrapped into a function initializeDavUi()