Skip to content

Commit 53353dc

Browse files
committed
normalize paths from windows to posix
1 parent 040cbdd commit 53353dc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

spec/unit/dependency_definition_spec.cr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ module Shards
4646
# Path short syntax
4747
expect_parses("./#{local_relative}", "path", "./#{local_relative}", Any)
4848
expect_parses("../#{local_relative}", "path", "../#{local_relative}", Any)
49-
expect_parses(".\\relative\\windows", "path", ".\\relative\\windows", Any)
50-
expect_parses("..\\relative\\windows", "path", "..\\relative\\windows", Any)
49+
{% if flag?(:windows) %}
50+
expect_parses(".\\relative\\windows", "path", "./relative/windows", Any)
51+
expect_parses("..\\relative\\windows", "path", "../relative/windows", Any)
52+
{% end %}
5153
# Path file schema
5254
expect_parses("file://#{local_relative}", "path", local_relative, Any)
5355
expect_parses("file://#{local_absolute}", "path", local_absolute, Any)

src/dependency_definition.cr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ module Shards
5555
end
5656

5757
# relative paths
58-
if value.starts_with?("./") || value.starts_with?("../") || value.starts_with?(".\\") || value.starts_with?("..\\")
58+
path = Path[value].to_posix.to_s
59+
if path.starts_with?("./") || path.starts_with?("../")
5960
resolver_key = "path"
60-
source = value
61+
source = path
6162
end
6263

6364
uri = URI.parse(value)

0 commit comments

Comments
 (0)