Skip to content

Commit 36d8da7

Browse files
authored
Merge pull request #1107 from julia-vscode/uri-win-file-case-insensitive
Make URI case insensitive for files on win
2 parents 7f5bfe9 + 5e7a273 commit 36d8da7

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

src/URIs2/URIs2.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,36 @@ struct URI
1212
fragment::Union{String,Nothing}
1313
end
1414

15+
@static if Sys.iswindows()
16+
function Base.:(==)(a::URI, b::URI)
17+
if a.scheme=="file" && b.scheme=="file"
18+
a_path_norm = lowercase(a.path)
19+
b_path_norm = lowercase(b.path)
20+
21+
return a.scheme == b.scheme &&
22+
a.authority == b.authority &&
23+
a_path_norm == b_path_norm &&
24+
a.query == b.query &&
25+
a.fragment == b.fragment
26+
else
27+
return a.scheme == b.scheme &&
28+
a.authority == b.authority &&
29+
a.path == b.path &&
30+
a.query == b.query &&
31+
a.fragment == b.fragment
32+
end
33+
end
34+
35+
function Base.hash(a::URI, h::UInt)
36+
if a.scheme=="file"
37+
path_norm = lowercase(a.path)
38+
return hash((a.scheme, a.authority, path_norm, a.query, a.fragment), h)
39+
else
40+
return hash((a.scheme, a.authority, a.path, a.query, a.fragment), h)
41+
end
42+
end
43+
end
44+
1545
function percent_decode(str::AbstractString)
1646
return URIs.unescapeuri(str)
1747
end

0 commit comments

Comments
 (0)