Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoimer committed Jun 29, 2023
1 parent 4fe8d71 commit 9276618
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/Alamofire/Alamofire.git",
"state": {
"branch": null,
"revision": "f82c23a8a7ef8dc1a49a8bfc6a96883e79121864",
"version": "5.5.0"
"revision": "bc268c28fb170f494de9e9927c371b8342979ece",
"version": "5.7.1"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let package = Package(
.library(name: "Fetch", targets: ["Fetch"]),
],
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "5.5.0"),
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "5.7.0"),
],
targets: [
.target(name: "Fetch",
Expand Down
22 changes: 16 additions & 6 deletions Sources/Fetch/Stub/Stub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public struct StubResponse: Stub {
/// - delay: Simulated network delay
/// - bundle: The `Bundle` containing the file, default Bundle.main
public init(statusCode: StatusCode, fileName: String, headers: HTTPHeaders = HTTPHeaders(), delay: TimeInterval, bundle: Bundle = Bundle.main) {
let split = fileName.split(separator: ".")
let name = String(split[0])
let fileExtension = String(split[1])
let fileExtension = fileName.fileExtension
let name = fileName.fileName

let path = bundle.path(forResource: name, ofType: fileExtension)!
var headersToUse = headers

Expand All @@ -65,9 +65,9 @@ public struct StubResponse: Stub {
}

public init(statusCode: StatusCode, fileName: String, directory: String, headers: HTTPHeaders = .init(), delay: TimeInterval, bundle: Bundle = .main) {
let split = fileName.split(separator: ".")
let name = String(split[0])
let fileExtension = String(split[1])
let fileExtension = fileName.fileExtension
let name = fileName.fileName

let path = bundle.path(forResource: name, ofType: fileExtension, inDirectory: directory)!

var headersToUse = headers
Expand Down Expand Up @@ -108,3 +108,13 @@ public struct StubError: Stub {
self.delay = delay
}
}

private extension String {
var fileName: String {
URL(fileURLWithPath: self).deletingPathExtension().lastPathComponent
}

var fileExtension: String {
URL(fileURLWithPath: self).pathExtension
}
}

0 comments on commit 9276618

Please sign in to comment.