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: normalize for allowedHosts #3720

Merged
merged 3 commits into from Aug 23, 2021
Merged

fix: normalize for allowedHosts #3720

merged 3 commits into from Aug 23, 2021

Conversation

anshumanv
Copy link
Member

  • 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?

not yet, will add once this fix is validated

Motivation / Use-Case

Fix webpack/webpack-cli#2909

Breaking Changes

no

Additional Info

@anshumanv anshumanv changed the title fix: fix normalize for allowedHosts fix: normalize for allowedHosts Aug 22, 2021
) {
options.allowedHosts = options.allowedHosts[0];
}

Copy link
Member

Choose a reason for hiding this comment

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

I think we should also account for allowedHosts: ['host1.com', 'host2.com', 'all']:

if (this.options.allowedHosts === "all") {

- if (this.options.allowedHosts === "all") { 
+ if (
+ this.options.allowedHosts === "all" || 
+ (Array.isArray(this.options.allowedHosts) && this.options.allowedHosts.includes("all"))
+ ) { 

What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

all and other hosts are mutually exclusive, I don't think there would be a use case for specifying other hosts with all 🤔 Maybe this would be the case for auto when we need to allow localhost along with other hosts

Copy link
Member

@snitin315 snitin315 Aug 22, 2021

Choose a reason for hiding this comment

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

Let's hear more opinions 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.

/cc @alexander-akait need slight attention 

is this okay or should we handle 'auto' too here

Copy link
Member

Choose a reason for hiding this comment

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

I will look at this in near future

Copy link
Member Author

Choose a reason for hiding this comment

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

will add tests once you confirm

Copy link
Member

Choose a reason for hiding this comment

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

I think it was mistake adding auto (because we already allow to handle from localhost/ip/etc), we should revisit this in the next major release, I will finish PR

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.

Let's add tests too

@alexander-akait alexander-akait marked this pull request as ready for review August 23, 2021 16:10
snitin315
snitin315 previously approved these changes Aug 23, 2021
@codecov
Copy link

codecov bot commented Aug 23, 2021

Codecov Report

Merging #3720 (debf428) into master (f563d1d) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3720      +/-   ##
==========================================
+ Coverage   93.20%   93.23%   +0.03%     
==========================================
  Files          15       15              
  Lines        1324     1331       +7     
  Branches      458      463       +5     
==========================================
+ Hits         1234     1241       +7     
  Misses         83       83              
  Partials        7        7              
Impacted Files Coverage Δ
lib/Server.js 93.63% <100.00%> (+0.05%) ⬆️

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 f563d1d...debf428. Read the comment docs.

@alexander-akait alexander-akait merged commit 326ed56 into master Aug 23, 2021
@alexander-akait alexander-akait deleted the allowed-hosts branch August 23, 2021 16:59
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.

Option --allowed-hosts all incorrectly parsed that lead to ignoring it by Server
3 participants