Skip to content

Commit

Permalink
Swap order of parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
joemasilotti committed Dec 12, 2024
1 parent 818793c commit bb4cf75
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Source/Bridge/UserAgent.swift
Original file line number Diff line number Diff line change
@@ -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)]"

Expand Down
4 changes: 2 additions & 2 deletions Source/HotwireConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions Tests/Bridge/UserAgentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
}
Expand Down

0 comments on commit bb4cf75

Please sign in to comment.