From 92766186a9e9325f8d4c495483371c433a794f76 Mon Sep 17 00:00:00 2001
From: Mathias Poimer <poimerm1@gmail.com>
Date: Thu, 29 Jun 2023 11:50:16 +0200
Subject: [PATCH] PR feedback

---
 Package.resolved              |  4 ++--
 Package.swift                 |  2 +-
 Sources/Fetch/Stub/Stub.swift | 22 ++++++++++++++++------
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/Package.resolved b/Package.resolved
index 878d8d2..83a47f5 100644
--- a/Package.resolved
+++ b/Package.resolved
@@ -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"
         }
       }
     ]
diff --git a/Package.swift b/Package.swift
index 24ac450..9f41683 100644
--- a/Package.swift
+++ b/Package.swift
@@ -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",
diff --git a/Sources/Fetch/Stub/Stub.swift b/Sources/Fetch/Stub/Stub.swift
index 8873b3a..ceaeffd 100644
--- a/Sources/Fetch/Stub/Stub.swift
+++ b/Sources/Fetch/Stub/Stub.swift
@@ -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
         
@@ -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
@@ -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
+    }
+}