Skip to content
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

fix: keep backward compatibility with event.node.req.url #471

Merged
merged 1 commit into from
Jul 31, 2023
Merged

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Jul 31, 2023

πŸ”— Linked issue

(failing tests against nuxt)

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR adds backward compatibility to the changes in #438 for event.path support. While we ideally could benefit from a single and normalized getter, it makes issues on edge cases when we are depending on legacy express like behavior (nuxt vite intention) to allow:

  • Supporting not normalized routes with double slashes (/module/@fs//...)
  • Supporting to manually modify event path by modifying event.node.req.url directly
  • Allowing to use custom modified URL in same tick

Because of this, this PR reverts event.path behavior to prefer future _path prop if exists and otherwise return (not normalized) node.req.url and also preserves node.req.originalPath

Also to avoid issues with same tick modification, app handler directly reads from event.node.req.url without depending on getter which strangely keeps failing when using getter.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov
Copy link

codecov bot commented Jul 31, 2023

Codecov Report

Merging #471 (44345e9) into main (51ec2bb) will increase coverage by 0.03%.
The diff coverage is 86.48%.

@@            Coverage Diff             @@
##             main     #471      +/-   ##
==========================================
+ Coverage   79.63%   79.66%   +0.03%     
==========================================
  Files          27       27              
  Lines        2980     2995      +15     
  Branches      436      442       +6     
==========================================
+ Hits         2373     2386      +13     
  Misses        607      607              
- Partials        0        2       +2     
Files Changed Coverage Ξ”
src/utils/request.ts 98.66% <80.00%> (+0.06%) ⬆️
src/utils/route.ts 93.33% <85.71%> (+3.85%) ⬆️
src/app.ts 97.34% <91.66%> (-0.35%) ⬇️
src/event/event.ts 73.68% <100.00%> (-2.00%) ⬇️

@pi0 pi0 merged commit 1f416c9 into main Jul 31, 2023
6 checks passed
@pi0 pi0 deleted the fix/h3-path branch July 31, 2023 10:18
@pi0 pi0 mentioned this pull request Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant