From 0cc13b146592fe386bb20dd2e96c11928372947a Mon Sep 17 00:00:00 2001 From: Alex Deem Date: Sun, 2 Jun 2024 10:47:30 +1000 Subject: [PATCH] Opt in to swift 5.9 rules for swiftformat --- .swift-version | 1 + .swiftformat | 1 - Sources/ScreamURITemplate/Internal/ValueFormatting.swift | 7 +++---- 3 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 .swift-version diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..b883184 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +5.9 \ No newline at end of file diff --git a/.swiftformat b/.swiftformat index 24a794d..9857c7f 100644 --- a/.swiftformat +++ b/.swiftformat @@ -1,4 +1,3 @@ ---swiftversion 5.7 --exclude .build # rules diff --git a/Sources/ScreamURITemplate/Internal/ValueFormatting.swift b/Sources/ScreamURITemplate/Internal/ValueFormatting.swift index 3a6626e..3684f78 100644 --- a/Sources/ScreamURITemplate/Internal/ValueFormatting.swift +++ b/Sources/ScreamURITemplate/Internal/ValueFormatting.swift @@ -47,11 +47,10 @@ func percentEncode(string: String, withAllowedCharacters allowedCharacterSet: Ch extension StringProtocol { func formatForTemplateExpansion(variableSpec: VariableSpec, expansionConfiguration: ExpansionConfiguration) throws -> String { - let modifiedValue: String - if let prefixLength = variableSpec.prefixLength() { - modifiedValue = String(prefix(prefixLength)) + let modifiedValue = if let prefixLength = variableSpec.prefixLength() { + String(prefix(prefixLength)) } else { - modifiedValue = String(self) + String(self) } let encodedExpansion = try percentEncode(string: modifiedValue, withAllowedCharacters: expansionConfiguration.percentEncodingAllowedCharacterSet, allowPercentEncodedTriplets: expansionConfiguration.allowPercentEncodedTriplets) if expansionConfiguration.named {