Skip to content

Commit f00023e

Browse files
sovaForNeVeR
authored andcommitted
simplify IsPrefixOf, fixed inheritdoc and updated README
1 parent eba7b4e commit f00023e

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ Aside from the strict types, the following features are supported for the paths:
8585

8686
(Note how `GetFileNameWithoutExtension()` works nicely together with `GetExtensionWithDot()` to reconstruct the resulting path from their concatenation, however weird the initial name was — no extension, trailing dot, no base name.)
8787

88+
### Unreleased
89+
90+
- `IPath::IsPrefixOf` to check path prefixes.
91+
- `IPath::StartsWith` to check if the current path starts with a specified path.
92+
8893
Documentation
8994
-------------
9095
- [Contributor Guide][docs.contributing]

TruePath/AbsolutePath.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ public AbsolutePath(LocalPath localPath) : this(localPath.Value, checkAbsolutene
5454
/// <inheritdoc cref="IPath.FileName"/>
5555
public string FileName => Underlying.FileName;
5656

57-
/// <inheritdoc cref="IPath.StartsWith"/>
57+
/// <inheritdoc cref="IPath{TPath}.StartsWith(TPath)"/>
5858
public bool StartsWith(AbsolutePath other) => Value.StartsWith(other.Value);
5959

60-
/// <inheritdoc cref="IPath.IsPrefixOf"/>
60+
/// <inheritdoc cref="IPath{TPath}.IsPrefixOf(TPath)"/>
6161
public bool IsPrefixOf(AbsolutePath other)
6262
{
63-
if (!(Value.Length <= other.Value.Length && other.Value.StartsWith(Value))) return false;
64-
return other.Value.Length == Value.Length || other.Value[Value.Length] == Path.DirectorySeparatorChar;
63+
return Value.Length <= other.Value.Length && other.Value.StartsWith(Value);
6564
}
6665

6766
/// <summary>

TruePath/LocalPath.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ public override int GetHashCode()
6969
return !left.Equals(right);
7070
}
7171

72-
/// <inheritdoc cref="IPath.StartsWith"/>
72+
/// <inheritdoc cref="IPath{TPath}.StartsWith(TPath)"/>
7373
public bool StartsWith(LocalPath other) => Value.StartsWith(other.Value);
7474

75-
/// <inheritdoc cref="IPath.IsPrefixOf"/>
75+
/// <inheritdoc cref="IPath{TPath}.IsPrefixOf(TPath)"/>
7676
public bool IsPrefixOf(LocalPath other)
7777
{
7878
if (!(Value.Length <= other.Value.Length && other.Value.StartsWith(Value))) return false;

0 commit comments

Comments
 (0)