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: fixed issues with req.url and added more tests #413

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

aarontravass
Copy link
Member

No description provided.

@aarontravass
Copy link
Member Author

@talentlessguy

packages/app/src/app.ts Show resolved Hide resolved
packages/app/src/request.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
tests/core/app.test.ts Outdated Show resolved Hide resolved
tests/core/app.test.ts Show resolved Hide resolved
tests/core/request.test.ts Outdated Show resolved Hide resolved
packages/app/src/request.ts Outdated Show resolved Hide resolved
packages/app/src/request.ts Outdated Show resolved Hide resolved
tests/core/app.test.ts Outdated Show resolved Hide resolved
tests/core/app.test.ts Show resolved Hide resolved
tests/fixtures/views/error.ejs Outdated Show resolved Hide resolved
tests/core/request.test.ts Outdated Show resolved Hide resolved
tests/core/request.test.ts Outdated Show resolved Hide resolved
packages/app/src/request.ts Outdated Show resolved Hide resolved
tests/core/request.test.ts Outdated Show resolved Hide resolved
const handle = (mw: Middleware) => async (req: Req, res: Res, next?: NextFunction) => {
const { path, handler, regex } = mw

req.url = reqUrlCopy // reset req.url since it is changed in the handle fn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we reset req.url here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have multiple middlewares for 1 path, the req.url is modified as per

req.url = lead(req.originalUrl.substring(prefix.length))

and hence, every single middleware after the first receives the altered req.url.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

req.url is supposed to be modified. It's different for subapps. that's why req.originalUrl exists

packages/app/src/request.ts Outdated Show resolved Hide resolved
packages/app/src/request.ts Show resolved Hide resolved
tests/core/request.test.ts Outdated Show resolved Hide resolved
@aarontravass aarontravass changed the title test: added tests for app, ip-filter, proxy-addr, rate-limit and req fix: fixed issues with req.url and added more tests Jan 30, 2024
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.

None yet

2 participants