Skip to content

Commit ce73b88

Browse files
kittaakoscmaglie
andauthored
Update uri.go
Co-authored-by: Cristian Maglie <[email protected]>
1 parent 68cc092 commit ce73b88

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

uri.go

+3-10
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,9 @@ func NewDocumentURI(path string) DocumentURI {
9292
encodedSegments[i] = segment
9393
} else {
9494
segment = lowercaseDriveSegment(segment)
95-
chars := strings.SplitAfter(segment, "")
96-
for i, c := range chars {
97-
// Spaces must be turned into `%20`. Otherwise, `url.QueryEscape`` encodes them to `+`.
98-
if c == " " {
99-
chars[i] = "%20"
100-
} else {
101-
chars[i] = url.QueryEscape(c)
102-
}
103-
}
104-
encodedSegments[i] = strings.Join(chars, "")
95+
segment = url.QueryEscape(segment)
96+
// Spaces must be turned into `%20`. Otherwise, `url.QueryEscape`` encodes them to `+`.
97+
encodedSegments[i] = strings.ReplaceAll(segment, "+", "%20")
10598
}
10699
}
107100
urlPath := strings.Join(encodedSegments, "/")

0 commit comments

Comments
 (0)