-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
@swift-server-bot test this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👌
@0xTim I probably don't have access to ask the bot to run the tests 🤔 |
@swift-server-bot test |
@swift-server-bot please test |
@swift-server-bot test this please |
@tomerd how do we trigger CI? 😅 |
I think @swift-server-bot is oof? 😆 |
@swift-server-bot test this please |
@marius-se as the error says - do you want to fix the |
I'm not at my desk, but as I see this, you could either not use the equtable conformance or use |
Correction: the spelling is |
We should fix the underlying issue since this is adding the conformance - we shouldn't be extending types we don't own to protocols we don't own. I didn't realise this was a new error but it's definitely a valid one, and one that Vapor is going to get screwed by 😅 |
@0xTim I was also worrying about that when I first reviewed, but @marius-se did it the "fine" way which is to only add it to Tests. That's why I'm fine with it existing. Totally removing it is also fine and might be slightly better as well. |
Sooooo... which option do you want me to proceed with 😆
(I'm happy with all three solutions) |
I think we can proceed with the third option and it should be fine 🙂 let path = try XCTUnwrap(app.routes.all.first?.path)
XCTAssertTrue(path == ["hello", ":name"], "Unexpected path: \(path)") But implementing func == (lhs: [PathComponent], rhs: [PathComponent]) -> Bool {
lhs.count == rhs.count &&
zip(lhs, rhs).allSatisfy {
/// Logic for `$0 == $1`, the same as you wrote for the Equatable conformance
}
} <Untested code alert, might not compile as-is> |
Or actually i didn't notice Tim recommending to fix the conformance in RoutingKit
That's fine by me too. |
You can hack it in for the tests, but I see no issue with adding it directly to RoutingKit as well |
@marius-se I think this should not be much of a problem now that the RoutingKit PR is merged. |
@swift-server-bot test this please |
@0xTim 🫣 |
@swift-server-bot test this please |
@swift-server-bot please test |
@MahdiBM feel free to merge and release once CI is green |
Currently all routes registered through this library will have an empty path component:
Example:
"/users" got split into ["", "users"]. With this PR "/users" will now be split into ["users"] only!