Skip to content

Commit

Permalink
support path instead of full url, fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
0xWDG committed May 10, 2024
1 parent 419320b commit 3c44bcf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,21 @@ networking.set(mockData: [
),
statusCode: 200, // Int: If omitted, 200 is used
error: nil
),
"/only/an/path": .init(
data: "OVERRIDE", // Can be Data or String
response: .init( // NSURLResponse, Can be nil
url: .init(stringLiteral: "https://wesleydegroot.nl/only/an/path"),
mimeType: "text/html",
expectedContentLength: 8,
textEncodingName: "utf-8"
),
statusCode: 200, // Int: If omitted, 200 is used
error: nil
)
])
```

### Debugging
```swift

Expand Down
10 changes: 9 additions & 1 deletion Sources/SimpleNetworking/SimpleNetworking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,15 @@ open class SimpleNetworking {
/// Set mock url data
/// - Parameter mock: Mock request.
public func set(mockData: [String: SNMock]) {
self.mockData = mockData
var newMockData: [String: SNMock] = [:]

for (url, mock) in mockData {
if let validURL = isURL(url) {
newMockData[validURL.absoluteString] = mock
}
}

self.mockData = newMockData
}

/// Add a cookie to the storage
Expand Down

0 comments on commit 3c44bcf

Please sign in to comment.