let abComponents: [PathComponent] = ["a", "b"]
let abRoutes = routes.grouped(abComponents)
try abRoutes.oAuth(
grouped: abComponents,
from: Google.self,
authenticate: "start",
callback: "http://localhost:8080/a/b/oauth/google",
scope: ["profile", "email"],
redirect: "/done")
// call to trigger... http://localhost:8080/a/b/start
Ungroued routes can omit the parameter. So existing usage should not change.
The parameter is passed down to FederatedServiceRouter configureRoutes(grouped:withAuthURL:authenticateCallback:on:) where the callback URL gets registered.
When breaking the callbackURL into path components, duplicate components at the head of the path are removed. So the grouped route is registered properly and matches the callback url.
Most of the work happens inside ImperialCore > Helpers > String + Tools.swift > pathComponents(grouped:)
Also added a few tests for different kinds of groups and callback urls.
Attempt to fix issue #43—Callback url registered incorrectly if using route groups.
It adds an optional parameter to
ServiceRegister
calledgrouped: [PathComponent]
Can be used with group routes like this...
Ungroued routes can omit the parameter. So existing usage should not change.
The parameter is passed down to FederatedServiceRouter
configureRoutes(grouped:withAuthURL:authenticateCallback:on:)
where the callback URL gets registered.When breaking the
callbackURL
into path components, duplicate components at the head of the path are removed. So the grouped route is registered properly and matches the callback url.Most of the work happens inside
ImperialCore
>Helpers
>String + Tools.swift
>pathComponents(grouped:)
Also added a few tests for different kinds of groups and callback urls.
Happy to add readme stuff if you like the fix.