diff --git a/Source/Bridge/UserAgent.swift b/Source/Bridge/UserAgent.swift index 374f311..b780e1b 100644 --- a/Source/Bridge/UserAgent.swift +++ b/Source/Bridge/UserAgent.swift @@ -1,7 +1,7 @@ import Foundation enum UserAgent { - static func build(componentTypes: [BridgeComponent.Type], applicationPrefix: String?) -> String { + static func build(applicationPrefix: String?, componentTypes: [BridgeComponent.Type]) -> String { let components = componentTypes.map { $0.name }.joined(separator: " ") let componentsSubstring = "bridge-components: [\(components)]" diff --git a/Source/HotwireConfig.swift b/Source/HotwireConfig.swift index f4b6d33..4cd7fd5 100644 --- a/Source/HotwireConfig.swift +++ b/Source/HotwireConfig.swift @@ -80,8 +80,8 @@ public struct HotwireConfig { let configuration = WKWebViewConfiguration() configuration.defaultWebpagePreferences?.preferredContentMode = .mobile configuration.applicationNameForUserAgent = UserAgent.build( - componentTypes: Hotwire.bridgeComponentTypes, - applicationPrefix: applicationUserAgentPrefix + applicationPrefix: applicationUserAgentPrefix, + componentTypes: Hotwire.bridgeComponentTypes ) configuration.processPool = sharedProcessPool return configuration diff --git a/Tests/Bridge/UserAgentTests.swift b/Tests/Bridge/UserAgentTests.swift index 3a7bb64..24cf311 100644 --- a/Tests/Bridge/UserAgentTests.swift +++ b/Tests/Bridge/UserAgentTests.swift @@ -5,24 +5,24 @@ import XCTest class UserAgentTests: XCTestCase { func testUserAgentSubstringWithNoComponents() { let userAgentSubstring = UserAgent.build( - componentTypes: [], - applicationPrefix: nil + applicationPrefix: nil, + componentTypes: [] ) XCTAssertEqual(userAgentSubstring, "Hotwire Native iOS; Turbo Native iOS; bridge-components: []") } func testUserAgentSubstringWithTwoComponents() { let userAgentSubstring = UserAgent.build( - componentTypes: [OneBridgeComponent.self, TwoBridgeComponent.self], - applicationPrefix: nil + applicationPrefix: nil, + componentTypes: [OneBridgeComponent.self, TwoBridgeComponent.self] ) XCTAssertEqual(userAgentSubstring, "Hotwire Native iOS; Turbo Native iOS; bridge-components: [one two]") } func testUserAgentSubstringCustomPrefix() { let userAgentSubstring = UserAgent.build( - componentTypes: [OneBridgeComponent.self, TwoBridgeComponent.self], - applicationPrefix: "Hotwire Demo;" + applicationPrefix: "Hotwire Demo;", + componentTypes: [OneBridgeComponent.self, TwoBridgeComponent.self] ) XCTAssertEqual(userAgentSubstring, "Hotwire Demo; Hotwire Native iOS; Turbo Native iOS; bridge-components: [one two]") }