source: trip-planner-front/node_modules/webpack-dev-server/lib/utils/createDomain.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 808 bytes
RevLine 
[6a3a178]1'use strict';
2
3const url = require('url');
4const ip = require('internal-ip');
5
6function createDomain(options, server) {
7 const protocol = options.https ? 'https' : 'http';
8 const hostname = options.useLocalIp
9 ? ip.v4.sync() || 'localhost'
10 : options.host || 'localhost';
11
12 // eslint-disable-next-line no-nested-ternary
13 const port = options.socket ? 0 : server ? server.address().port : 0;
14 // use explicitly defined public url
15 // (prefix with protocol if not explicitly given)
16 if (options.public) {
17 return /^[a-zA-Z]+:\/\//.test(options.public)
18 ? `${options.public}`
19 : `${protocol}://${options.public}`;
20 }
21 // the formatted domain (url without path) of the webpack server
22 return url.format({
23 protocol,
24 hostname,
25 port,
26 });
27}
28
29module.exports = createDomain;
Note: See TracBrowser for help on using the repository browser.