-
Notifications
You must be signed in to change notification settings - Fork 62
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
fix(data-explorer): opening documents with _ids with slashes VSCODE-276 #342
Conversation
src/editors/editorsController.ts
Outdated
const regularExpression = /[\\\/]/gi; | ||
displayName = displayName.replace(regularExpression, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a dumb question, is it important that these are unique, i.e. is it a problem to match a/b
and ab
to the same display name? If so, maybe encodeURIComponent()
makes sense here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that would be a better way to do it, good thinking. I'll update. Looks like that collision would have caused an error saying you can't change _id which would be nice to avoid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@addaleax Updated it to encode these characters. Also started encoding the namespace since it's possible to have some special characters in a collection name.
Open and editing this document works so I think we're good? The display name can be less nice looking with a lot of those characters, but I think it makes sense and works as expected. We're not encoding everything here because vscode uses the file name as the file title and we want the file name to look as close to the data as possible (it will decode and try to parse the /
). I'll add a note to mention in docs that we're encoding special characters here so the display name might not quite match the _id value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VSCODE-276
We were opening documents with the virtual file name with a slash in it which made VSCode think it was in a folder and couldn't find it. This PR updates it so that now we trim these special characters from the file name before displaying them.
Also added a playground useful for seeding a db with some docs with different kinds of _ids.
Addresses #284
open.different._ids.mp4