Skip to content

Make URL template regex dependency framework-only for now #1268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Sources/FoundationEssentials/URL/URLTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ extension URL {
}

// MARK: - Parse

#if FOUNDATION_FRAMEWORK
extension URL.Template {
/// Creates a new template from its text form.
///
Expand Down Expand Up @@ -164,6 +164,7 @@ extension URL.Template {
}
}
}
#endif

// MARK: -

Expand Down
5 changes: 5 additions & 0 deletions Sources/FoundationEssentials/URL/URLTemplate_Expression.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
//
//===----------------------------------------------------------------------===//

#if FOUNDATION_FRAMEWORK
internal import RegexBuilder
#endif

#if canImport(CollectionsInternal)
internal import CollectionsInternal
#elseif canImport(OrderedCollections)
Expand Down Expand Up @@ -79,6 +82,7 @@ extension URL.Template.Expression.Element: CustomStringConvertible {
}
}

#if FOUNDATION_FRAMEWORK
extension URL.Template.Expression {
init(_ input: String) throws {
var remainder = input[...]
Expand Down Expand Up @@ -202,6 +206,7 @@ extension URL.Template {
}
}
}
#endif

// .------------------------------------------------------------------.
// | NUL + . / ; ? & # |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
//
//===----------------------------------------------------------------------===//

#if FOUNDATION_FRAMEWORK
internal import RegexBuilder
#endif

extension String {
/// Convert to NFC and percent-escape.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import struct Foundation.URL
#endif
import Testing

#if FOUNDATION_FRAMEWORK
@Suite("URL.Template Expression")
private enum ExpressionTests {
private typealias Expression = URL.Template.Expression
Expand Down Expand Up @@ -276,3 +277,4 @@ private enum ExpressionTests {
#expect((try? Expression(input)) == nil, "Should fail to parse, but not crash.")
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private var variables: [URL.Template.VariableName: URL.Template.Value] {
]
}

#if FOUNDATION_FRAMEWORK
private func assertReplacing(template: String, result: String, sourceLocation: SourceLocation = #_sourceLocation) {
do {
let t = try #require(URL.Template(template))
Expand Down Expand Up @@ -263,3 +264,4 @@ private enum TemplateTests {
assertReplacing(template: "{&keys*}", result: "&semi=%3B&dot=.&comma=%2C")
}
}
#endif