-
Notifications
You must be signed in to change notification settings - Fork 474
path: appending local paths to external paths #14278
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - Use `/` as directory separator when appending local paths to external paths, | ||
| making path construction consistent across platforms. (#14278, @Alizter) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -27,7 +27,24 @@ let to_dyn t = Dyn.variant "External" [ Dyn.string t ] | |||||
| let relative x y = | ||||||
| match y with | ||||||
| | "." -> x | ||||||
| | _ -> Filename.concat x y | ||||||
| | _ -> | ||||||
| let y = | ||||||
| if String.length y >= 2 && y.[0] = '.' && is_dir_sep y.[1] | ||||||
| then String.drop y 2 | ||||||
| else y | ||||||
| in | ||||||
| (match y with | ||||||
| | "" | "." -> x | ||||||
| | _ -> | ||||||
| (* Strip a trailing directory separator from [x] so we don't produce | ||||||
| double slashes (e.g. "/root/" + "foo" -> "/root/foo"). We use | ||||||
| [is_dir_sep] so that on Windows a trailing '\' is also removed, | ||||||
| normalising the join to always use '/'. *) | ||||||
| let x = | ||||||
| let len = String.length x in | ||||||
| if len > 0 && is_dir_sep x.[len - 1] then String.take x (len - 1) else x | ||||||
| in | ||||||
| x ^ "/" ^ y) | ||||||
|
Alizter marked this conversation as resolved.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm unsure about this suggestion, but I always wonder if it isn't better (potentially less allocation) to use
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That seems better thanks. |
||||||
| ;; | ||||||
|
|
||||||
| let append_local t local = relative t (Local.to_string local) | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.