Skip to content

Commit 681512a

Browse files
committed
Fixed b0rked basic auth
Works now. The parsing got b0rked when converting to Swift 4 strings, I suppose.
1 parent 860b1b1 commit 681512a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/http/BasicAuth.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public extension BasicAuthModule {
3838
#if canImport(Foundation) // `String.Encoding.utf8`, provide alternative!
3939
/**
4040
* Extract HTTP Basic authentication credentials (name/pass) from the given
41-
* ```IncomingMessage```.
41+
* ``IncomingMessage``.
4242
*
4343
* - Parameters:
4444
* - request: The ``IncomingMessage`` containing the `Authorization`
@@ -81,7 +81,7 @@ public extension BasicAuthModule {
8181
throw BasicAuthError.differentAuthorization
8282
}
8383

84-
let payload = String(authString[authString.index(after: idx)])
84+
let payload = String(authString[authString.index(after: idx)...])
8585
.trimmingCharacters(in: .whitespacesAndNewlines)
8686

8787
guard let data = Data(base64Encoded: payload) else {
@@ -98,7 +98,7 @@ public extension BasicAuthModule {
9898

9999
return Credentials(
100100
name: String(string[string.startIndex..<colIdx]),
101-
pass: String(string[colIdx..<string.endIndex])
101+
pass: String(string[string.index(after: colIdx)..<string.endIndex])
102102
)
103103
}
104104
#endif // canImport(Foundation)

0 commit comments

Comments
 (0)