• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supabase-swift / 13049867283

30 Jan 2025 10:00AM UTC coverage: 56.699% (+4.2%) from 52.465%
13049867283

push

github

web-flow
chore: coverage badge on REDME

4816 of 8494 relevant lines covered (56.7%)

13.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.54
/Sources/Helpers/HTTP/HTTPFields.swift
1
import HTTPTypes
2

3
extension HTTPFields {
4
  package init(_ dictionary: [String: String]) {
297✔
5
    self.init(dictionary.map { .init(name: .init($0.key)!, value: $0.value) })
320✔
6
  }
297✔
7

8
  package var dictionary: [String: String] {
13✔
9
    let keyValues = self.map {
46✔
10
      ($0.name.rawName, $0.value)
46✔
11
    }
46✔
12

13✔
13
    return .init(keyValues, uniquingKeysWith: { $1 })
13✔
14
  }
13✔
15

16
  package mutating func merge(with other: Self) {
2✔
17
    for field in other {
7✔
18
      self[field.name] = field.value
7✔
19
    }
7✔
20
  }
2✔
21

22
  package func merging(with other: Self) -> Self {
140✔
23
    var copy = self
140✔
24

140✔
25
    for field in other {
140✔
26
      copy[field.name] = field.value
65✔
27
    }
140✔
28

140✔
29
    return copy
140✔
30
  }
140✔
31

32
  /// Append or update a value in header.
33
  ///
34
  /// Example:
35
  /// ```swift
36
  /// var headers: HTTPFields = [
37
  ///   "Prefer": "count=exact,return=representation"
38
  /// ]
39
  ///
40
  /// headers.appendOrUpdate(.prefer, value: "return=minimal")
41
  /// #expect(headers == ["Prefer": "count=exact,return=minimal"]
42
  /// ```
43
  package mutating func appendOrUpdate(
44
    _ name: HTTPField.Name,
45
    value: String,
46
    separator: String = ","
47
  ) {
×
48
    if let currentValue = self[name] {
×
49
      var components = currentValue.components(separatedBy: separator)
×
50

×
51
      if let key = value.split(separator: "=").first,
×
52
        let index = components.firstIndex(where: { $0.hasPrefix("\(key)=") })
×
53
      {
×
54
        components[index] = value
×
55
      } else {
×
56
        components.append(value)
×
57
      }
×
58

×
59
      self[name] = components.joined(separator: separator)
×
60
    } else {
×
61
      self[name] = value
×
62
    }
×
63
  }
×
64
}
65

66
extension HTTPField.Name {
67
  package static let xClientInfo = HTTPField.Name("X-Client-Info")!
68
  package static let xRegion = HTTPField.Name("x-region")!
69
  package static let xRelayError = HTTPField.Name("x-relay-error")!
70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc