Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(hono-base): remove unneeded processes and variables #3649

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/hono-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string =
this.#addRoute(method, this.#path, args1)
}
args.forEach((handler) => {
if (typeof handler !== 'string') {
this.#addRoute(method, this.#path, handler)
}
this.#addRoute(method, this.#path, handler)
})
return this as any
}
Expand Down Expand Up @@ -489,15 +487,17 @@ class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string =
executionCtx?: ExecutionContext
): Response | Promise<Response> => {
if (input instanceof Request) {
if (requestInit !== undefined) {
input = new Request(input, requestInit)
}
return this.fetch(input, Env, executionCtx)
return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx)
}
input = input.toString()
const path = /^https?:\/\//.test(input) ? input : `http://localhost${mergePath('/', input)}`
const req = new Request(path, requestInit)
return this.fetch(req, Env, executionCtx)
return this.fetch(
new Request(
/^https?:\/\//.test(input) ? input : `http://localhost${mergePath('/', input)}`,
requestInit
),
Env,
executionCtx
)
}

/**
Expand Down
Loading