-
-
Notifications
You must be signed in to change notification settings - Fork 146
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 optional parameter "add_trailing_slash" #360
Conversation
The problem is that when you remove the trailing slash path matching using Wouldn't it make more sense to append a trailing slash on any incoming requests that don't have it? |
Yes, I agree it'd make more sense to add the trailing slash at the end of the incoming requests, but I just couldn't get that to work with Next.js (#359), I know it's a problem there but I did could get what I wanted to work by modifying this library so I thought It'd be good for everyone else to have this option. I checked the example you gave and you're right, when the Socket.IO's endpoint is set to Got this when connecting to the
But this happens when trying to reach
This is just as you described but this didn't happen to me when my endpoint was
and my
Requests such as
Does the |
What I mean is that you can append a |
Hmm, I hadn't thought in that, I should do it that way, thanks for the recommendation, I think I'll apply it; but wouldn't it be possible to add this as an option given that Socket.IO allows it? |
I guess, but only if it worked correctly. As I said above, matching the URL is harder without that trailing slash as a delimiter. |
I'll try to get it working correctly and will submit the commit. |
A solution that requires no configuration like the one I propose would be preferable. There is really not much of a point in having the application explicitly add or remove the trailing slash, since the server can easily support both with the change I suggested. The configuration option should be to disable this behavior, in the odd case it causes a problem. |
You mean the option should be |
The default behavior should be that you provide your endpoint with or without trailing slash, and the server accepts the endpoint with or without trailing slash. This should work in pretty much all cases without any need to add configuration. I think just doing this would be an improvement. If there has to be configuration, rather than doing what the JS server did, I would implement the default as I just described, and then add an option to disable automatic handling, which means that if you provide an endpoint with trailing slash then that is the only accepted URL, and if you provide one without trailing slash again that is the only endpoint that is accepted. But I honestly don't see a need to have this as an option since the default should work just fine for everybody. In the future, if it turns out I'm wrong and there is some use case unknown to me that cannot be implemented due to the automatic slash handling, then we can look into adding an option to disable it. |
I think the approach that you are taking is more complex that it needs to be. I have committed a simpler solution now, let me know what you think! |
It works perfectly! Thank you for listening my petition and fixing my code. Hope this get available soon in the stable release. |
As I stated at #359, It would be nice to have the option of whether add or not the trailing slash at the end of the Socket.IO's endpoint.