Skip to content

check res.getHeader type before exec #381

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

Closed
wants to merge 2 commits into from
Closed

Conversation

sjy
Copy link

@sjy sjy commented Mar 7, 2019

@sjy sjy requested a review from alexander-akait as a code owner March 7, 2019 12:58
@jsf-clabot
Copy link

jsf-clabot commented Mar 7, 2019

CLA assistant check
All committers have signed the CLA.

@sjy sjy changed the title Fix middleware check res.getHeader type before exec Mar 7, 2019
@codecov
Copy link

codecov bot commented Mar 7, 2019

Codecov Report

Merging #381 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #381   +/-   ##
=======================================
  Coverage   96.96%   96.96%           
=======================================
  Files           7        7           
  Lines         264      264           
=======================================
  Hits          256      256           
  Misses          8        8
Impacted Files Coverage Δ
lib/middleware.js 94.54% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dba5e02...3b47e15. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Mar 7, 2019

Codecov Report

Merging #381 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #381   +/-   ##
=======================================
  Coverage   96.96%   96.96%           
=======================================
  Files           7        7           
  Lines         264      264           
=======================================
  Hits          256      256           
  Misses          8        8
Impacted Files Coverage Δ
lib/middleware.js 94.54% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dba5e02...3b47e15. Read the comment docs.

@@ -1,6 +1,6 @@
{
"name": "webpack-dev-middleware",
"version": "3.6.1",
"version": "3.6.2",
Copy link
Member

Choose a reason for hiding this comment

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

Avoid this

@@ -79,7 +79,7 @@ module.exports = function wrapper(context) {
contentType += '; charset=UTF-8';
}

if (!res.getHeader('Content-Type')) {
if (!res.getHeader || (typeof res.getHeader === 'function' && !res.getHeader('Content-Type'))) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we simplify this? Looks very misleading, like:

if (res.getHeader && !res.getHeader('Content-Type')) {
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the question to be answered first is: What to do in the case where res.getHeader is not available. Execute the if statement or not?

@sjy in your statement you will execute the if statement when res.getHeader is not available. Is it correct, that set Header function is available though?

Copy link
Author

Choose a reason for hiding this comment

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

since the use case only effects project using the latest webpack-koa which will be fixed, this pr is will be closed. @dmohns, thanks your attention, code changes here is more like a hot-fix.

Copy link
Author

Choose a reason for hiding this comment

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

since the use case only effects project using the latest webpack-koa which will be fixed, this pr is will be closed. @dmohns, thanks your attention, code changes here is more like a hot-fix.

@jqueryisamonad
Copy link

There is no need for this pull request. It's a problem with koa wrapper which does not provide a getHeader method.

shellscape/koa-webpack#110

@sjy sjy closed this Mar 7, 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.

5 participants