Skip to content

Commit 5d12358

Browse files
authored
(166098325) Fix resolution for fragment-only relative URLs (swiftlang#1702)
1 parent d512200 commit 5d12358

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

Sources/FoundationEssentials/URL/URL_Resolution.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,14 @@ internal func resolveURLBuffers<
333333
writeIndex = absoluteBuffer[writeIndex...].initialize(
334334
fromSpan: relativeSpan.extracting(relativePathRange.endIndex...)
335335
)
336-
} else if baseHeader.hasQuery {
337-
// No relative query, copy the base query including the leading "?"
338-
let baseQueryRange = baseHeader.queryRange
339-
writeIndex = absoluteBuffer[writeIndex...].initialize(
340-
fromSpan: baseSpan.extracting((baseQueryRange.startIndex - 1)..<baseQueryRange.endIndex)
341-
)
336+
} else {
337+
if baseHeader.hasQuery {
338+
// No relative query, copy the base query including the leading "?"
339+
let baseQueryRange = baseHeader.queryRange
340+
writeIndex = absoluteBuffer[writeIndex...].initialize(
341+
fromSpan: baseSpan.extracting((baseQueryRange.startIndex - 1)..<baseQueryRange.endIndex)
342+
)
343+
}
342344
// Copy the relative fragment, if present
343345
writeIndex = absoluteBuffer[writeIndex...].initialize(
344346
fromSpan: relativeSpan.extracting(relativePathRange.endIndex...)

0 commit comments

Comments
 (0)