-
Notifications
You must be signed in to change notification settings - Fork 284
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
Add HTTPServerRequest.routerRootDir property #1301
Conversation
This idea sounds useful, I worked around this by hand for some projects already. For new projects , something similar for I see a two issues with the concrete approach:
|
… dispatching request
I'm trying to use Path, but I can't figure out how to wrangle it into submission. Path path = Path([PathEntry("a"), PathEntry("deep"), PathEntry("path")], true);
Path root = Path([PathEntry(".."), PathEntry(".."), PathEntry("..")], true);
string routerRootDir = path.relativeTo(root).toString; Everything else causes the assert at path.d:145 to fail. How do I properly go about this? |
It should be |
That doesn't seem to be quite right either. For paths without a trailing slash, it leaves off the topmost path component. E.g. Edit: I should mention this is how the browser handles it. |
Hm right, forgot about that, this issue just came up somewhere else recently. Trailing slash handling doesn't quite match the rules needed here. This should fix it:
|
Ok, I think that's all the edge cases ironed out. Thanks for the help. |
Thanks, looks good. |
Add HTTPServerRequest.routerRootDir property
This allows for emitting the correct path when using a URLRouter with a prefix.
Consider the index of a router with prefix "/a/deep/path" which renders:
The following is output: