ForNeVeR / ForNeVeR/TruePath

Relative-only paths

Open
#23 0 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue help wanted
Dominant language
C#
Stars
104
Forks
15
Avg merge
9m
Merged PRs (30d)
2

Description

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:
```csharp
struct RelativePath
{
public RelativePath(string path, bool trimLeadingSlash = false) { … }
}
```

Examples:
```csharp
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.