ondras / my-mind

Online Mindmapping Software
https://my-mind.github.io
MIT License
3.28k stars 648 forks source link

Save URI only populates directory when URL is set in query string #169

Open melvincarvalho opened 1 year ago

melvincarvalho commented 1 year ago

I'm having an issue with saving my mind map. When I load a mind map from a URL in the query string, it loads fine. However, when I try to save it, the input box in the save area only populates the directory.

Here's the URL I'm using:

https://nosdav.com/my-mind/?url=https%3A%2F%2Fnosdav.nostr.rocks%2Fde7ecd1e2976a6adb2ffa5f4db81a7d812c8bb6698aa00dcf1e76adb55efd645%2Fnostr.json

image

As you can see in the attached screenshot, I was expecting the filename to be at the end, so instead, I have to type it manually. Is there something that can be done to fix this issue?

Thanks in advance for your help!

melvincarvalho commented 1 year ago

This code snippet is a workaround

const urlParam = new URLSearchParams(window.location.search).get('url');
const urlElement = document.querySelector('.url');
if (urlElement && urlParam) {
  urlElement.value = urlParam;
}
melvincarvalho commented 1 year ago

I see the issue is here

        if (url.match(/\.mymind$/)) { // complete file name
        } else { // just a path
            if (url.charAt(url.length-1) != "/") { url += "/"; }
            url += `${map.name}.${formatRepo.get("native")!.extension}`;
        }

https://github.com/ondras/my-mind/blob/master/src/ui/backend/webdav.ts#L38

If extension is mymind it will save, else it adds / + root node

I wonder if it's worth adding .json to this

ondras commented 1 year ago

My memories might be completely off, but I think that saving is supposed to work like this:

In other words, if you use "save as", you are supposed to provide an explicit new file name (url suffix).

This is the place where the url-without-the-file-name is being extracted during map load: https://github.com/ondras/my-mind/blob/master/src/ui/backend/webdav.ts#L60