TruePath icon indicating copy to clipboard operation
TruePath copied to clipboard

Relative-only paths

Open ForNeVeR opened this issue 10 months ago • 0 comments

Currently, we have the following two types for paths:

  • AbsolutePath for, well, absolute paths,
  • LocalPath for any paths.

We lack a separate type to specify a relative-only type, so let's get one. @PaGrom makes a good argument on its existence, see https://github.com/ForNeVeR/TruePath/issues/1#issuecomment-1113823321.

I propose the following design:

struct RelativePath
{
  public RelativePath(string path, bool trimLeadingSlash = false) { … }
}

Examples:

new RelativePath("foo/bar") // => foo/bar
new RelativePath("/foo/bar", trimLeadingSlash = true) // => foo/bar
new RelativePath("/foo/bar"); // exception

Whether trimLeadingSlash should be true or false by default I am not sure. @PaGrom, what do you think? I would lean towards more strict behavior by default.

See TODO[#23] in the project sources when implementing this.

ForNeVeR avatar Apr 21 '24 20:04 ForNeVeR