Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GlobalNavigationPathProvider: change definition for the newRelativePath #835

Merged
merged 1 commit into from
Mar 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -98,7 +98,11 @@ public GlobalNavigationPathProvider(GlobalNavigationFile navigationFile, Assembl
}

var originalPath = Path.Combine(match.Host, match.AbsolutePath.Trim('/')).TrimStart('/');
var newRelativePath = relativePath.AsSpan().TrimStart(originalPath).TrimStart('/').ToString();
var relativePathSpan = relativePath.AsSpan();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! We have a few misuses of TrimStart() on Span<T> 😢

Maybe as a follow up PR put this in a new extension method TrimStartExact() and update other places we misused TrimStart().

var newRelativePath = relativePathSpan.StartsWith(originalPath, StringComparison.Ordinal)
? relativePathSpan.Slice(originalPath.Length).TrimStart('/').ToString()
: relativePathSpan.TrimStart(originalPath).TrimStart('/').ToString();

var path = fs.Path.Combine(outputDirectory.FullName, toc.SourcePathPrefix, newRelativePath);

return fs.FileInfo.New(path);

Unchanged files with check annotations Beta

TODO write development documentation here
![Image outside of scope](../images/great-drawing-of-new-structure.png)

Check notice on line 10 in docs/development/index.md

GitHub Actions / build

Image '../images/great-drawing-of-new-structure.png' is referenced out of table of contents scope '/home/runner/work/docs-builder/docs-builder/docs/development'.