-
Notifications
You must be signed in to change notification settings - Fork 140
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
feat: disable semicolon separator by default #336
Conversation
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.
This is really weird, but it looks like it's correct. Can you provide a bench results?
@mcollina This is a major for find-my-way.
@@ -88,6 +88,7 @@ function Router (opts) { | |||
this.maxParamLength = opts.maxParamLength || 100 | |||
this.allowUnsafeRegex = opts.allowUnsafeRegex || false | |||
this.constrainer = new Constrainer(opts.constraints) | |||
this.useSemicolonDelimiter = opts.useSemicolonDelimiter || false |
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.
Don't forget to set it true
in the Fastify.
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.
Ideally this option should be disabled in Fastify as well, but I don't know the best way to do it: leave the default false
here and open issue/PR to update dependencies in Fastify, or make it true
here and send PR to Fastify with the option disabled
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.
I would leave the false
here, because it's a correct behavior and we can release a new major of fmw at any moment. In current version of Fastify it should be set to true
by default, because otherwise it's a breaking change.
About changing it to false
in the fastify in a future release. It's better to open an issue about this in fastify, but IMHO it never would be set to true
by defauld in the Fastify, because it will break too many apps. It just doesn't worth it even if it's true according to the spec.
// Thus, we need to split on `;` as well as `?` and `#`. | ||
} else if (charCode === 63 || charCode === 59 || charCode === 35) { | ||
// Thus, we need to split on `;` as well as `?` and `#` if the useSemicolonDelimiter option is enabled. | ||
} else if (charCode === 63 || charCode === 35 || (useSemicolonDelimiter && charCode === 59)) { | ||
querystring = path.slice(i + 1) |
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.
If there is any perf difference (I doubt), you can move the useSemicolonDelimiter
additional check under the charCode
checking if
. That would remove it from a hot path.
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.
Yes, given that the ;
symbol is rare, that's correct. I fixed
I made a simple example in the sandbox btw, it works the same way for the |
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
@levensta did you run the benchmarks by any chance? |
I run |
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.
Can you document the new option?
@mcollina I've updated the README. But I am still confused by the fact that there is still a |
I'm lost. can you make an example? |
In this example, you can see that both |
That does not look correct, what does the rfc say? |
This PR comes from the discussion in the issue (fastify/fastify#5050). I've added a new parameter that allows the
;
character to be used to separate path and query as before, but its default value isfalse
to be fully compliant with the RFC