Closed RyanGreenup closed 4 months ago
I pushed without running the tests and they failed.
The is_dir()
requires the directory to exist on the fs and otherwise
returns false
, I adjusted the tests to reflect that behaviour and
added it to the docstring of the function.
The .is_relative()
will always be true
. Maybe test for component::Parent
in file_path
?
The
.is_relative()
will always betrue
. Maybe test forcomponent::Parent
infile_path
?
At first I was using that to check for ../
as you pointed out, but I re-considered and now the logic is:
false
: Resolve based on absolute path, this would be useful for e.g. vim opening notes from in a different working directorytrue
:
false
: Resolve based on absolute path
true
: Resolve based on the relative path, this way the user doesn't see long URLI'm happy with this now if you wanted to pull. Alternatively, if there's any feedback, I'm happy to fix.
This PR is pristine. Thank you for all the work you put into this. Approved.
This improves the link resolution to also resolve relative links.
This is done by:
.is_relative()
)PathBuf::from("/home/user/Notes/Code/index.md").join("../Linux/index.md")
..
.canonicalize()
method is not appropriate here as it tries to resolve symlinks and panics when the file doesn't exist.Consideration
We could simply call the
.canonicalize()
method and leave the link alone if that fails:std::path::Comonent
enum changes