-
-
Notifications
You must be signed in to change notification settings - Fork 463
fix: [Issue-2437] Rewrites should support special symbols in dynamic routes #2440
fix: [Issue-2437] Rewrites should support special symbols in dynamic routes #2440
Conversation
Handler Size Report
Base Handler Sizes (kB) (commit e6367b5){
"Lambda": {
"Default Lambda": {
"Standard": 1578,
"Minified": 692
},
"Image Lambda": {
"Standard": 1543,
"Minified": 831
}
},
"Lambda@Edge": {
"Default Lambda": {
"Standard": 1588,
"Minified": 698
},
"Default Lambda V2": {
"Standard": 1580,
"Minified": 694
},
"API Lambda": {
"Standard": 634,
"Minified": 318
},
"Image Lambda": {
"Standard": 1551,
"Minified": 835
},
"Regeneration Lambda": {
"Standard": 1233,
"Minified": 566
},
"Regeneration Lambda V2": {
"Standard": 1307,
"Minified": 596
}
}
} New Handler Sizes (kB) (commit 182ac60){
"Lambda": {
"Default Lambda": {
"Standard": 1578,
"Minified": 692
},
"Image Lambda": {
"Standard": 1543,
"Minified": 831
}
},
"Lambda@Edge": {
"Default Lambda": {
"Standard": 1588,
"Minified": 698
},
"Default Lambda V2": {
"Standard": 1580,
"Minified": 694
},
"API Lambda": {
"Standard": 634,
"Minified": 318
},
"Image Lambda": {
"Standard": 1551,
"Minified": 835
},
"Regeneration Lambda": {
"Standard": 1233,
"Minified": 566
},
"Regeneration Lambda V2": {
"Standard": 1307,
"Minified": 596
}
}
} |
Codecov Report
@@ Coverage Diff @@
## master #2440 +/- ##
==========================================
+ Coverage 83.85% 83.88% +0.02%
==========================================
Files 102 102
Lines 3717 3717
Branches 1191 1191
==========================================
+ Hits 3117 3118 +1
+ Misses 588 587 -1
Partials 12 12
Continue to review full report at Codecov.
|
packages/libs/core/src/match.ts
Outdated
@@ -32,7 +32,7 @@ export function compileDestination( | |||
) { | |||
// Handle external URL redirects | |||
const { origin, pathname, search } = new URL(destination); | |||
const toPath = compile(pathname, { encode: encodeURIComponent }); | |||
const toPath = compile(pathname); |
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.
Question: Instead of removing the encoding entirely, would it make sense to use encodeURI
?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
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.
Hi, thanks for the suggestion.
I've checked how the next.js server works with path matching and the difference is quite significant.
However, the usage of encodeURI
makes the behavior a little bit closer.
It will encode not-ASCII chars but will not encode symbols like @=.
a455602
to
182ac60
Compare
A proposal for fixing «Rewrites don't work with special symbols in a URL»
Issue reference.
Summary of the issue:
@
and=
@
and=
all of the above works in the Next.js server
I followed the code and found no reason for using encoders in the rewrite mechanism.
the next code:
should prevent wrong path matching from the beginning.
Also, the
compile
function should not produce an invalid path sincevalidation
is enabled by default@dphang Am I missing something?