Skip to content

Refactoring checkHost #1619

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

Merged
merged 3 commits into from
Jan 9, 2019
Merged

Refactoring checkHost #1619

merged 3 commits into from
Jan 9, 2019

Conversation

orenfromberg
Copy link
Contributor

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

Motivation / Use-Case

I found the second condition in this line confusing:
https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L751

      if (!this.checkHost(connection.headers) || !this.checkHost(connection.headers, 'origin')) {

Specifically checkHost(connection.headers, 'origin'). The function is ostensibly going to check the Host header but in fact it is really checking the host described by the Origin header.

In order to make code easier to reason about, I refactored this to:

      if (!this.checkHost(connection.headers) || !this.checkOrigin(connection.headers)) {

Breaking Changes

Additional Info

@jsf-clabot
Copy link

jsf-clabot commented Jan 6, 2019

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Thanks!

@alexander-akait alexander-akait merged commit 349e733 into webpack:master Jan 9, 2019
carlosgeos pushed a commit to carlosgeos/webpack-dev-server that referenced this pull request Feb 26, 2019
* Refactoring checkHost and adding Origin check

* Removing unnecessary header check

* Adding semicolons
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.

3 participants