sumbit test code
This commit is contained in:
parent
bb0b0169c7
commit
31f822e27d
5 changed files with 12 additions and 5 deletions
|
@ -1,12 +1,10 @@
|
|||
import { getNetworkAddress } from './get-network-address.js'
|
||||
|
||||
export function getResolvedHostForHttpServer(host: string | boolean) {
|
||||
if (host === false) {
|
||||
// Use a secure default
|
||||
return 'localhost';
|
||||
} else if (host === true) {
|
||||
// If passed --host in the CLI without arguments
|
||||
return getNetworkAddress(); // undefined typically means 0.0.0.0 or :: (listen on all IPs)
|
||||
return undefined; // undefined typically means 0.0.0.0 or :: (listen on all IPs)
|
||||
} else {
|
||||
return host;
|
||||
}
|
||||
|
@ -19,4 +17,3 @@ export function stripBase(path: string, base: string): string {
|
|||
const baseWithSlash = base.endsWith('/') ? base : base + '/';
|
||||
return path.replace(RegExp('^' + baseWithSlash), '/');
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
|
||||
"build:ci": "astro-scripts build \"src/**/*.ts\"",
|
||||
"dev": "astro-scripts dev \"src/**/*.ts\"",
|
||||
"t": "mocha --exit --timeout 20000 test/url-protocol.test.js",
|
||||
"test": "mocha --exit --timeout 20000 test/"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -2,6 +2,7 @@ import type { CreatePreviewServer } from 'astro';
|
|||
import type http from 'node:http';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { createServer } from './http-server.js';
|
||||
import { getNetworkAddress } from './get-network-address.js'
|
||||
import type { createExports } from './server';
|
||||
|
||||
const preview: CreatePreviewServer = async function ({
|
||||
|
@ -58,6 +59,10 @@ const preview: CreatePreviewServer = async function ({
|
|||
return pathname;
|
||||
}
|
||||
|
||||
if (!host){
|
||||
host = getNetworkAddress()
|
||||
}
|
||||
|
||||
const server = createServer(
|
||||
{
|
||||
client,
|
||||
|
|
|
@ -5,5 +5,9 @@
|
|||
"dependencies": {
|
||||
"astro": "workspace:*",
|
||||
"@astrojs/node": "workspace:*"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "astro build",
|
||||
"preview": "astro preview"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue