Skip to content

Commit 91a6698

Browse files
authored
Add prefix support to resolvedPath (and tests) (#6)
1 parent dd87733 commit 91a6698

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Sources/RoutingMacros/RoutingMacros.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public struct RoutingMacro: ExtensionMacro {
176176

177177
let prefixedPath = "\(prefix ?? "")\(route.path)"
178178

179-
for component in route.path.split(separator: "/") {
179+
for component in prefixedPath.split(separator: "/") {
180180
if component.first == "{" {
181181
let name = String(component.dropFirst().dropLast())
182182
captured.append(name)

Tests/TestPrefix.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,10 @@ struct MacroRoutingTestPrefix {
4646
}
4747
}
4848
}
49+
50+
@Test("Resolved Path")
51+
func testPathResolution() async throws {
52+
#expect(Controller.$Routing.auth.path == "/api/auth")
53+
#expect(Controller.$Routing.deauthId.resolvedPath(id: "test") == "/api/deauth/test")
54+
}
4955
}

0 commit comments

Comments
 (0)