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] Middleware: Allow usage without express server #188

Merged
merged 1 commit into from
May 27, 2019

Conversation

matz3
Copy link
Member

@matz3 matz3 commented May 24, 2019

This makes all middlewares independent of the express specific
req.path property by manually parsing the standard req.url.

The parseurl library is also used within express and makes sure to
not parse the same URL of a request object again by using a cache on
the request object.

Follow up of #184

Fixes: SAP/karma-ui5#64

Thank you for your contribution! 🙌

To get it merged faster, kindly review the checklist below:

Pull Request Checklist

This makes all middlewares independent of the express specific
`req.path` property by manually parsing the standard `req.url`.

The `parseurl` library is also used within express and makes sure to
not parse the same URL of a request object again by using a cache on
the request object.

Follow up of #184

Fixes: SAP/karma-ui5#64
matz3 added a commit to SAP/karma-ui5 that referenced this pull request May 24, 2019
@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 93.284% when pulling 6b36348 on fix-middleware-url-handling into 498cf6b on master.

Copy link
Member

@codeworrior codeworrior left a comment

Choose a reason for hiding this comment

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

LGTM.

When I made the change for the CSP middleware, I thought about an additional test without express to ensure the desired use case. But the necessary setup seemed to be quite complex, so I abandoned that idea.

If we have more scenarios than just the legacy grunt tooling, having such a test might make sense. What do you think?

@matz3
Copy link
Member Author

matz3 commented May 27, 2019

I also thought about this. Currently most of the time we just mock the req/res objects and call the middleware directly. This should be fine as long as we don't provide other properties like path, which could be done wrong when introducing a new middleware.

So some integration tests with plain Node http, connect and express would be a good thing.

@matz3 matz3 merged commit 4d971b4 into master May 27, 2019
@matz3 matz3 deleted the fix-middleware-url-handling branch May 27, 2019 19:37
matz3 added a commit to SAP/karma-ui5 that referenced this pull request Jun 6, 2019
matz3 added a commit to SAP/karma-ui5 that referenced this pull request Jun 17, 2019
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.

UI5 Tooling Middleware does not serve files when url contains a query
4 participants