the-forest/client/node_modules/.cache/babel-loader/a0df467c574b6a68d875d6a42427e7c61bc25e755753a0c72c92e1cde85c186f.json

1 line
13 KiB
JSON
Raw Normal View History

2024-09-17 20:35:18 -04:00
{"ast":null,"code":"/**\n * @param {{ protocol?: string, auth?: string, hostname?: string, port?: string, pathname?: string, search?: string, hash?: string, slashes?: boolean }} objURL\n * @returns {string}\n */\nfunction format(objURL) {\n var protocol = objURL.protocol || \"\";\n if (protocol && protocol.substr(-1) !== \":\") {\n protocol += \":\";\n }\n var auth = objURL.auth || \"\";\n if (auth) {\n auth = encodeURIComponent(auth);\n auth = auth.replace(/%3A/i, \":\");\n auth += \"@\";\n }\n var host = \"\";\n if (objURL.hostname) {\n host = auth + (objURL.hostname.indexOf(\":\") === -1 ? objURL.hostname : \"[\".concat(objURL.hostname, \"]\"));\n if (objURL.port) {\n host += \":\".concat(objURL.port);\n }\n }\n var pathname = objURL.pathname || \"\";\n if (objURL.slashes) {\n host = \"//\".concat(host || \"\");\n if (pathname && pathname.charAt(0) !== \"/\") {\n pathname = \"/\".concat(pathname);\n }\n } else if (!host) {\n host = \"\";\n }\n var search = objURL.search || \"\";\n if (search && search.charAt(0) !== \"?\") {\n search = \"?\".concat(search);\n }\n var hash = objURL.hash || \"\";\n if (hash && hash.charAt(0) !== \"#\") {\n hash = \"#\".concat(hash);\n }\n pathname = pathname.replace(/[?#]/g,\n /**\n * @param {string} match\n * @returns {string}\n */\n function (match) {\n return encodeURIComponent(match);\n });\n search = search.replace(\"#\", \"%23\");\n return \"\".concat(protocol).concat(host).concat(pathname).concat(search).concat(hash);\n}\n\n/**\n * @param {URL & { fromCurrentScript?: boolean }} parsedURL\n * @returns {string}\n */\nfunction createSocketURL(parsedURL) {\n var hostname = parsedURL.hostname;\n\n // Node.js module parses it as `::`\n // `new URL(urlString, [baseURLString])` parses it as '[::]'\n var isInAddrAny = hostname === \"0.0.0.0\" || hostname === \"::\" || hostname === \"[::]\";\n\n // why do we need this check?\n // hostname n/a for file protocol (example, when using electron, ionic)\n // see: https://github.com/webpack/webpack-dev-server/pull/384\n if (isInAddrAny && self.location.hostname && self.location.protocol.indexOf(\"http\") === 0) {\n hostname = self.location.hostname;\n }\n var socketURLProtocol = parsedURL.protocol || self.location.protocol;\n\n // When https is used in the app, secure web sockets are always necessary because the browser doesn't accept non-secure web sockets.\n if (socketURLProtocol === \"auto:\" || hostname && isInAddrAny && self.location.protocol === \"https:\") {\n socketURLProtocol = self.location.protocol;\n }\n socketURLProtocol = socketURLProtocol.replace(/^(?:http|.+-extension|file)/i, \"ws\");\n var socketURLAuth = \"\";\n\n // `new URL(urlString, [baseURLstring])` doesn't have `auth` property\n // Parse authentication credentials in case we need them\n if (parsedURL.username) {\n socketURLAuth = parsedURL.username;\n\n // Since HTTP basic authentication does not allow empty username,\n // we only include password if the username is not empty.\n if (parsedURL.password) {\n // Result: <username>:<password>\n socketURLAuth = socketURLAuth.concat(\":\", parsedURL.password);\n }\n }\n\n // In case the host is a raw IPv6 address, it can be enclosed in\n // the brackets as the brackets are needed in the final URL string.\n // Need to remove those as url.format blindly adds its own set of brackets\n // if the host string contains colons. That would lead to non-working\n // double brackets (e.g. [[::]]) host\n //\n // All of these web socket url params are optionally passed in through resourceQuery,\n // so we need to fall back to the default if they are not provided\n var socketURLHostname = (hostname || self.location.hostname || \"localhost\").replace(/^\\[(.*)\\]$/, \"$1\");\n var socketURLPort = parsedURL.port;\n if (!socketURLPort || socketURLPort === \"0\") {\n socketURLPort = self.location.port;\n }\n\n // If path is provided it'll be passed in via the resourceQuery as a\n // query param so i