-
Notifications
You must be signed in to change notification settings - Fork 580
fix(express): Ensure 404 routes don't attach route attribute #2843
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
base: main
Are you sure you want to change the base?
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.
LGTM! thank you for your contribution @s1gr1d 🙂
cc @raphael-theriault-swi, @JamieDanielson, @pkanal (component owners)
oh - looks like there are some lint errors, you can fix them by running |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2843 +/- ##
==========================================
+ Coverage 89.69% 89.73% +0.03%
==========================================
Files 185 186 +1
Lines 9034 9085 +51
Branches 1852 1875 +23
==========================================
+ Hits 8103 8152 +49
- Misses 931 933 +2
🚀 New features to boost your workflow:
|
I have to look into this again. I see another test is failing. It doesn't add |
The problem was that the layers look the same if a non-existing route is requested or the root is requested: So in order to know if it was a 404 route, I added a utility function that does some additional checking. I made sure that the existing tests still work and added some more tests for the utility function. |
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 @s1gr1d, thanks for following up on this.
It seems that this PR is based on a commit that's a little over 2 months old. Would you mind rebasing it on top of main
it so that we can see how this would fit in with the current state? 🙂
6592b20
to
99a94d2
Compare
99a94d2
to
006539c
Compare
if (constructedRoute.includes('/') && | ||
(constructedRoute.includes(',') || | ||
constructedRoute.includes('\\') || | ||
constructedRoute.includes('*') || | ||
constructedRoute.includes('['))) { |
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 condition is for considering regex routes (without this, the regex tests would fail). This should cover most cases.
There is a previous conversation about this: #2008 (comment)
@pichlermarc I rebased it and aligned the code so the "regex" tests don't fail anymore. |
Which problem is this PR solving?
This is an upstream fix for getsentry/sentry-javascript#16211
Instead of adding
/
to non-existing routes, it sets the attribute toundefined
, which makes it clear it's a non-existing route and not the index route.A tricky thing is that the layers look the same if a non-existing route is requested or the root is requested:
['/', '/']
./existing
-->['/', '/existing']
/non-existing
-->['/', '/']
/
-->['/', '/']
So in order to know if it was a 404 route, a utility function that does some additional checking was added.