Completed abs_path new constructor for windows#2
Open
landonwork wants to merge 4 commits intonomad:mainfrom
Open
Completed abs_path new constructor for windows#2landonwork wants to merge 4 commits intonomad:mainfrom
landonwork wants to merge 4 commits intonomad:mainfrom
Conversation
noib3
requested changes
Nov 30, 2025
core/src/abs_path.rs
Outdated
| #[cfg(windows)] | ||
| fn new(original_str: &'a str) -> Result<Self, NormalizeError> { | ||
| if matches!(original_str.chars().next(), Some('a'..='z' | 'A'..='Z')) && &original_str[1..3] == ":\\" { | ||
| if matches!(original_str.chars().next(), Some('a'..='z' | 'A'..='Z')) && &original_str[1..4] == ":\\" { |
Contributor
There was a problem hiding this comment.
[1..4] panics if the string is shorter than 4 bytes. Use get(1..cursor) instead.
core/src/abs_path.rs
Outdated
| fn new(original_str: &'a str) -> Result<Self, NormalizeError> { | ||
| if matches!(original_str.chars().next(), Some('a'..='z' | 'A'..='Z')) && &original_str[1..3] == ":\\" { | ||
| if matches!(original_str.chars().next(), Some('a'..='z' | 'A'..='Z')) && &original_str[1..4] == ":\\" { | ||
| let cursor = 4; // e.g. "C:\\" |
Contributor
There was a problem hiding this comment.
Can you define the cursor outside the if? That way we can use it as the upper bound when slicing instead of having 2 sources of truth.
Also, shouldn't it be set to 3? C:\ is 3 bytes long.
Author
|
This is a quick fix. I would like to get nomad working on my Windows machine. Sorry I don't have more time today. I did address your comments. A couple notes:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added correct absolute path validation for windows: https://learn.microsoft.com/en-us/answers/questions/862484/regex-to-validate-a-valid-windows-folder-directory