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

Conversation

cotti
Copy link
Contributor

@cotti cotti commented Mar 25, 2025

Fixes #830

The issue is a subtle behavior detail on TrimStart() (and TrimEnd()). Rather than acting akin to Substring(), it continues to try and remove more of the input being manipulated as long as a character belongs in the trim set, until it finds a character not belonging to it.

Anyhow, the default behavior has been changed to verify if it starts with the originalPath, and if it does, perform a Slice() instead.

@cotti cotti added the fix label Mar 25, 2025
@cotti cotti self-assigned this Mar 25, 2025
@cotti cotti requested a review from a team as a code owner March 25, 2025 04:34
Copy link
Member

@reakaleek reakaleek left a comment

Choose a reason for hiding this comment

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

LGTM. Nice find!

@@ -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().

@Mpdreamz Mpdreamz merged commit 0e11be6 into main Mar 25, 2025
11 checks passed
@Mpdreamz Mpdreamz deleted the fix/assembler_path_provider_relative_path branch March 25, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[assembler] Pages not found when built locally
3 participants