Skip to content

Commit

Permalink
Fix spelling error
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdeem committed Jun 10, 2024
1 parent c40686d commit b0d833a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ struct ExpansionConfiguration {
let prefix: String?
let separator: String
let named: Bool
let omittOrphanedEquals: Bool
let omitOrphanedEquals: Bool
}
16 changes: 8 additions & 8 deletions Sources/ScreamURITemplate/Internal/ExpressionOperator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,56 +33,56 @@ enum ExpressionOperator: Unicode.Scalar {
prefix: nil,
separator: ",",
named: false,
omittOrphanedEquals: false)
omitOrphanedEquals: false)
case .reserved:
return ExpansionConfiguration(percentEncodingAllowedCharacterSet: reservedAndUnreservedCharacterSet,
allowPercentEncodedTriplets: true,
prefix: nil,
separator: ",",
named: false,
omittOrphanedEquals: false)
omitOrphanedEquals: false)
case .fragment:
return ExpansionConfiguration(percentEncodingAllowedCharacterSet: reservedAndUnreservedCharacterSet,
allowPercentEncodedTriplets: true,
prefix: "#",
separator: ",",
named: false,
omittOrphanedEquals: false)
omitOrphanedEquals: false)
case .label:
return ExpansionConfiguration(percentEncodingAllowedCharacterSet: unreservedCharacterSet,
allowPercentEncodedTriplets: false,
prefix: ".",
separator: ".",
named: false,
omittOrphanedEquals: false)
omitOrphanedEquals: false)
case .pathSegment:
return ExpansionConfiguration(percentEncodingAllowedCharacterSet: unreservedCharacterSet,
allowPercentEncodedTriplets: false,
prefix: "/",
separator: "/",
named: false,
omittOrphanedEquals: false)
omitOrphanedEquals: false)
case .pathStyle:
return ExpansionConfiguration(percentEncodingAllowedCharacterSet: unreservedCharacterSet,
allowPercentEncodedTriplets: false,
prefix: ";",
separator: ";",
named: true,
omittOrphanedEquals: true)
omitOrphanedEquals: true)
case .query:
return ExpansionConfiguration(percentEncodingAllowedCharacterSet: unreservedCharacterSet,
allowPercentEncodedTriplets: false,
prefix: "?",
separator: "&",
named: true,
omittOrphanedEquals: false)
omitOrphanedEquals: false)
case .queryContinuation:
return ExpansionConfiguration(percentEncodingAllowedCharacterSet: unreservedCharacterSet,
allowPercentEncodedTriplets: false,
prefix: "&",
separator: "&",
named: true,
omittOrphanedEquals: false)
omitOrphanedEquals: false)
}
}
}
8 changes: 4 additions & 4 deletions Sources/ScreamURITemplate/Internal/ValueFormatting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private extension StringProtocol {
}
let encodedExpansion = try percentEncode(string: modifiedValue, withAllowedCharacters: expansionConfiguration.percentEncodingAllowedCharacterSet, allowPercentEncodedTriplets: expansionConfiguration.allowPercentEncodedTriplets)
if expansionConfiguration.named {
if encodedExpansion.isEmpty && expansionConfiguration.omittOrphanedEquals {
if encodedExpansion.isEmpty && expansionConfiguration.omitOrphanedEquals {
return String(variableSpec.name)
}
return "\(variableSpec.name)=\(encodedExpansion)"
Expand All @@ -101,7 +101,7 @@ private extension Array where Element: StringProtocol {
}
let expansion = encodedExpansions.joined(separator: separator)
if expansionConfiguration.named {
if expansion.isEmpty && expansionConfiguration.omittOrphanedEquals {
if expansion.isEmpty && expansionConfiguration.omitOrphanedEquals {
return String(variableSpec.name)
}
return "\(variableSpec.name)=\(expansion)"
Expand All @@ -114,7 +114,7 @@ private extension Array where Element: StringProtocol {
let encodedExpansions = try map { element -> String in
let encodedElement = try percentEncode(string: String(element), withAllowedCharacters: expansionConfiguration.percentEncodingAllowedCharacterSet, allowPercentEncodedTriplets: expansionConfiguration.allowPercentEncodedTriplets)
if expansionConfiguration.named {
if encodedElement.isEmpty && expansionConfiguration.omittOrphanedEquals {
if encodedElement.isEmpty && expansionConfiguration.omitOrphanedEquals {
return String(variableSpec.name)
}
return "\(variableSpec.name)=\(encodedElement)"
Expand Down Expand Up @@ -150,7 +150,7 @@ private extension [TypedVariableValue.AssociativeArrayElement] {
let encodedExpansions = try map { key, value -> String in
let encodedKey = try percentEncode(string: String(key), withAllowedCharacters: expansionConfiguration.percentEncodingAllowedCharacterSet, allowPercentEncodedTriplets: expansionConfiguration.allowPercentEncodedTriplets)
let encodedValue = try percentEncode(string: String(value), withAllowedCharacters: expansionConfiguration.percentEncodingAllowedCharacterSet, allowPercentEncodedTriplets: expansionConfiguration.allowPercentEncodedTriplets)
if expansionConfiguration.named && encodedValue.isEmpty && expansionConfiguration.omittOrphanedEquals {
if expansionConfiguration.named && encodedValue.isEmpty && expansionConfiguration.omitOrphanedEquals {
return String(variableSpec.name)
}
return "\(encodedKey)=\(encodedValue)"
Expand Down

0 comments on commit b0d833a

Please sign in to comment.