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

fixed ipv6 ip parsing and listening at [::] #673

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions bin/webpack-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,21 @@ function processOptions(wpOpt) {

var protocol = options.https ? "https" : "http";

/**
* the formated uri of the webpack server
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove this comment or make it more descriptive? Atm this tells me nothing more then I already know from looking at the code.

If you make it more descriptive, be sure to use // instead.

*/
var uri = url.format({
protocol: protocol,
hostname: options.host,
port: options.port.toString()
});

if(options.inline !== false) {
var devClient = [require.resolve("../client/") + "?" + protocol + "://" + (options.public || (options.host + ":" + options.port))];
/**
* client query url public or formated uri
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

*/
var query = options.public ? (protocol + "://" + options.public) : uri;
var devClient = [require.resolve("../client/") + "?" + query];

if(options.hotOnly)
devClient.push("webpack/hot/only-dev-server");
Expand Down Expand Up @@ -302,12 +315,8 @@ function processOptions(wpOpt) {
new Server(compiler, options).listen(options.port, options.host, function(err) {
if(err) throw err;

var uri = url.format({
protocol: protocol,
hostname: options.host,
port: options.port.toString(),
pathname: options.inline !== false ? "/" : "webpack-dev-server/"
});
//add the pathname of uri
uri += options.inline !== false ? "/" : "webpack-dev-server/"
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this a separate variable instead? It's hackish to override the variable in this case since in query it's used for something else.

console.log(" " + uri);

console.log("webpack result is served from " + options.publicPath);
Expand Down
4 changes: 3 additions & 1 deletion client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ var onSocketMsg = {
var hostname = urlParts.hostname;
var protocol = urlParts.protocol;

if(urlParts.hostname === "0.0.0.0") {

//check ipv4 and ipv6 `all hostname`
if(hostname === "0.0.0.0" || hostname === "::") {
// why do we need this check?
// hostname n/a for file protocol (example, when using electron, ionic)
// see: https://github.com/webpack/webpack-dev-server/pull/384
Expand Down