Skip to content
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

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

Open
melvincarvalho opened this issue Apr 5, 2023 · 3 comments
Open

Comments

@melvincarvalho
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Owner

ondras commented Apr 5, 2023

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

  • "save" button overwrites previous data; in order to do so, the complete URL must be known
  • "save as" is supposed to create a (differently-named) copy; therefore, only the incomplete path is extracted into the input field during the load operation

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants