Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 250cdaa

Browse files
author
Wenjie Xia
committed
refactor: clean up
1 parent 02e6d9d commit 250cdaa

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

server/mod.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { path, serve, ws } from '../deps.ts'
1+
import { path, serve as stdServe, ws } from '../deps.ts'
22
import { hashShort, reHashJs, reModuleExt } from '../shared/constants.ts'
33
import { existsFileSync } from '../shared/fs.ts'
44
import log from '../shared/log.ts'
@@ -25,7 +25,7 @@ export class Server {
2525
}
2626

2727
const app = this.#app
28-
const url = new URL('http://localhost/' + r.url)
28+
const url = new URL('http://localhost' + r.url)
2929
const pathname = util.cleanPath(decodeURI(url.pathname))
3030
const req = new Request(r, pathname, {}, url.searchParams)
3131

@@ -158,12 +158,11 @@ export class Server {
158158
}
159159
}
160160

161-
export async function start(hostname: string, port: number, app: Appliaction) {
161+
export async function serve(hostname: string, port: number, app: Appliaction) {
162162
const server = new Server(app)
163-
164163
while (true) {
165164
try {
166-
const s = serve({ hostname, port })
165+
const s = stdServe({ hostname, port })
167166
log.info(`Server ready on http://${hostname}:${port}`)
168167
for await (const r of s) {
169168
server.handle(r)

shared/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export const TB = KB ** 4
55
export const PB = KB ** 5
66
export const hashShort = 9
77
export const reHttp = /^https?:\/\//i
8-
export const reModuleExt = /\.(js|jsx|mjs|ts|tsx)$/i
9-
export const reStyleModuleExt = /\.(pcss|css)$/i
8+
export const reModuleExt = /\.(jsx?|tsx?|mjs)$/i
9+
export const reStyleModuleExt = /\.p?css$/i
1010
export const reLocaleID = /^[a-z]{2}(-[a-zA-Z0-9]+)?$/
1111
export const reFullVersion = /@v?\d+\.\d+\.\d+/i
1212
export const reHashJs = new RegExp(`\\.[0-9a-fx]{${hashShort}}\\.js$`, 'i')

0 commit comments

Comments
 (0)