Skip to content
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

Fix empty path component in route registration #13

Merged
merged 3 commits into from
Jan 9, 2024
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
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-runtime.git", from: "1.0.0"),
.package(url: "https://github.com/vapor/vapor.git", from: "4.86.2"),
.package(url: "https://github.com/vapor/vapor.git", from: "4.91.1"),
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.2.0")
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIVapor/VaporTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ extension [Vapor.PathComponent] {
init(_ path: String) {
self = path.split(
separator: "/",
omittingEmptySubsequences: false
omittingEmptySubsequences: true
).map { parameter in
if parameter.first == "{", parameter.last == "}" {
return .parameter(String(parameter.dropFirst().dropLast()))
Expand Down
5 changes: 4 additions & 1 deletion Tests/OpenAPIVaporTests/VaporTransportTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class VaporTransportTests: XCTestCase {
override func tearDown() async throws {
app.shutdown()
}

func testHeadRequestExplicitContentLength() async throws {
let transport = VaporTransport(routesBuilder: app)
let response = HTTPTypes.HTTPResponse(
Expand Down Expand Up @@ -112,6 +112,9 @@ final class VaporTransportTests: XCTestCase {
method: .post,
path: "/hello/{name}"
)

XCTAssertTrue(app.routes.all.first?.path == ["hello", ":name"])

try app.test(
.POST,
"/hello/Maria?greeting=Howdy",
Expand Down