foambubble / foam

A personal knowledge management and sharing system for VSCode
https://foambubble.github.io/
Other
15.45k stars 663 forks source link

Slugifier creates files named like `foo/.md` if the title ends in slash #1042

Closed tv42 closed 2 years ago

tv42 commented 2 years ago

Describe the bug

Note titles ending in slashes create files like foo/.md. That's a dot file, hidden by many tools by default, and usually intended to contain something other than your regular file content.

I discovered this while messing with templates, trying to take notes about webpages, with the URL as a title.

I think the slugifier should remove trailing slashes.

Different language, but just for background: I wrote a slugifier in Go at https://github.com/tv42/slug where I specifically put attention into handling this kind of input. It munges the input more, flattening it into a single directory (https://github.com/tv42/slug -> github-com-tv42-slug), which you may or may not like, but feel free to steal the tests https://github.com/tv42/slug/blob/2fc6af481f773c93cac07009d43047f16f17ca7f/slug_test.go#L13-L20 or grab ideas from the implementation: https://github.com/tv42/slug/blob/master/slug.go

Small Reproducible Example

No response

Steps to Reproduce the Bug or Issue

Control-shift-P, "Foam: Create New Note", and enter as title "foo/". The created file will be foo/.md.

Expected behavior

I expect end-user tools to not create dotfiles accidentally.

Screenshots or Videos

No response

Operating System Version

NixOS 22.05 (Linux)

Visual Studio Code Version

1.68.1

Additional context

No response

riccardoferretti commented 2 years ago

fixed in 0.19.2