formatting changes

b43ac187ec606bce4f489a066e0960522e7d313d

BPplays <andymalbp@gmail.com>

2 files changed, +15 -0Ignore whitespace
server.js+12 -0
@@ -735,6 +735,8 @@ const preSetupTasks = async function () {
735735
736/**736/**
737 * Gets the hostname to use for autorun in the browser.737 * Gets the hostname to use for autorun in the browser.
738 * @param {boolean} useIPv6 If use IPv6
739 * @param {boolean} useIPv4 If use IPv4
738 * @returns Promise<string> The hostname to use for autorun740 * @returns Promise<string> The hostname to use for autorun
739 */741 */
740async function getAutorunHostname(useIPv6, useIPv4) {742async function getAutorunHostname(useIPv6, useIPv4) {
@@ -861,6 +863,8 @@ function logSecurityAlert(message) {
861 * Handles the case where the server failed to start on one or both protocols.863 * Handles the case where the server failed to start on one or both protocols.
862 * @param {boolean} v6Failed If the server failed to start on IPv6864 * @param {boolean} v6Failed If the server failed to start on IPv6
863 * @param {boolean} v4Failed If the server failed to start on IPv4865 * @param {boolean} v4Failed If the server failed to start on IPv4
866 * @param {boolean} useIPv6 If use IPv6
867 * @param {boolean} useIPv4 If use IPv4
864 */868 */
865function handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4) {869function handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4) {
866 if (v6Failed && !useIPv4) {870 if (v6Failed && !useIPv4) {
@@ -882,6 +886,7 @@ function handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4) {
882/**886/**
883 * Creates an HTTPS server.887 * Creates an HTTPS server.
884 * @param {URL} url The URL to listen on888 * @param {URL} url The URL to listen on
889 * @param {number} ipVersion the ip version to use
885 * @returns {Promise<void>} A promise that resolves when the server is listening890 * @returns {Promise<void>} A promise that resolves when the server is listening
886 * @throws {Error} If the server fails to start891 * @throws {Error} If the server fails to start
887 */892 */
@@ -909,6 +914,7 @@ function createHttpsServer(url, ipVersion) {
909/**914/**
910 * Creates an HTTP server.915 * Creates an HTTP server.
911 * @param {URL} url The URL to listen on916 * @param {URL} url The URL to listen on
917 * @param {number} ipVersion the ip version to use
912 * @returns {Promise<void>} A promise that resolves when the server is listening918 * @returns {Promise<void>} A promise that resolves when the server is listening
913 * @throws {Error} If the server fails to start919 * @throws {Error} If the server fails to start
914 */920 */
@@ -929,6 +935,12 @@ function createHttpServer(url, ipVersion) {
929 });935 });
930}936}
931937
938
939/**
940 * Starts the server using http or https depending on config
941 * @param {boolean} useIPv6 If use IPv6
942 * @param {boolean} useIPv4 If use IPv4
943 */
932async function startHTTPorHTTPS(useIPv6, useIPv4) {944async function startHTTPorHTTPS(useIPv6, useIPv4) {
933 let v6Failed = false;945 let v6Failed = false;
934 let v4Failed = false;946 let v4Failed = false;
src/util.js+3 -0
@@ -696,6 +696,7 @@ export function isValidUrl(url) {
696/**696/**
697 * removes starting `[` or ending `]` from hostname.697 * removes starting `[` or ending `]` from hostname.
698 * @param {string} hostname hostname to use698 * @param {string} hostname hostname to use
699 * @returns {string} hostname plus the modifications
699 */700 */
700export function urlHostnameToIPv6(hostname) {701export function urlHostnameToIPv6(hostname) {
701 if (hostname.startsWith('[')) {702 if (hostname.startsWith('[')) {
@@ -712,6 +713,7 @@ export function urlHostnameToIPv6(hostname) {
712 * @param {string} name Domain name to use713 * @param {string} name Domain name to use
713 * @param {boolean} useIPv6 If use IPv6714 * @param {boolean} useIPv6 If use IPv6
714 * @param {boolean} useIPv4 If use IPv4715 * @param {boolean} useIPv4 If use IPv4
716 * @returns Promise<boolean> If the URL is valid
715 */717 */
716export async function canResolve(name, useIPv6 = true, useIPv4 = true) {718export async function canResolve(name, useIPv6 = true, useIPv4 = true) {
717 try {719 try {
@@ -747,6 +749,7 @@ export async function canResolve(name, useIPv6 = true, useIPv4 = true) {
747/**749/**
748 * converts string to boolean accepts 'true' or 'false' else it returns the string put in750 * converts string to boolean accepts 'true' or 'false' else it returns the string put in
749 * @param {string} str Input string751 * @param {string} str Input string
752 * @returns {boolean|string} boolean else original input string
750 */753 */
751export function stringToBool(str) {754export function stringToBool(str) {
752 if (str === 'true') return true;755 if (str === 'true') return true;