Skip to content

Commit

Permalink
fix: update user agent apollo metadata format
Browse files Browse the repository at this point in the history
  • Loading branch information
5d committed Aug 28, 2024
1 parent 36a06cc commit 9068483
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class PackageInfo {
let compilerInfo = "lang/swift#\(swiftVersion)"
let osInfo = "os/\(name)#\(version)"
let libInfo = "lib/aws-appsync-apollo-extensions-swift#\(Self.version)"
let dependenciesInfo = "md/apollo#\(Constants.ApolloVersion)"
let dependenciesInfo = "md/apollo-ios#\(Constants.ApolloVersion)"

return "UA/2.0 \(compilerInfo) \(osInfo) \(libInfo) \(dependenciesInfo)"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import XCTest
class PackageInfoTests: XCTestCase {

/// user agent header has format of:
/// UA/2.0 lang/swift/x.x(.x) os/[iOS, macOS, watchOS]/x.x(.x) lib/aws-appsync-apollo-extensions-swift/x.x.x
/// UA/2.0 lang/swift#x.x(.x) os/[iOS, macOS, watchOS]#x.x(.x) lib/aws-appsync-apollo-extensions-swift#x.x.x md/apollo-ios#x.x.x
func testUserAgentHasCorrectFormat() async throws {
let pattern = "^UA/2\\.0 " +
"lang/swift#\\d+\\.\\d+(?:\\.\\d+)? " +
"os/(?:iOS|macOS|watchOS|tvOS)#\\d+\\.\\d+(?:\\.\\d+)? " +
"lib/aws-appsync-apollo-extensions-swift#\\d+\\.\\d+\\.\\d+ " +
"md/apollo#\\d+\\.\\d+\\.\\d+$"
"md/apollo-ios#\\d+\\.\\d+\\.\\d+$"
let regex = try NSRegularExpression(pattern: pattern)
let userAgent = await PackageInfo.userAgent
let matches = regex.numberOfMatches(in: userAgent, options: [], range: NSRange(location: 0, length: userAgent.utf8.count))
Expand Down

0 comments on commit 9068483

Please sign in to comment.