diff --git a/deps.test.ts b/deps.test.ts index a188725..3f40b73 100644 --- a/deps.test.ts +++ b/deps.test.ts @@ -1,3 +1,3 @@ -export {assertEquals} from "https://deno.land/std@0.203.0/assert/mod.ts"; -export {dirname, fromFileUrl} from "https://deno.land/std@0.203.0/path/mod.ts"; -export {exists} from "https://deno.land/std@0.203.0/fs/mod.ts"; \ No newline at end of file +export {assertEquals} from "https://deno.land/std@0.207.0/assert/mod.ts"; +export {dirname, fromFileUrl} from "https://deno.land/std@0.207.0/path/mod.ts"; +export {exists} from "https://deno.land/std@0.207.0/fs/mod.ts"; \ No newline at end of file diff --git a/deps.ts b/deps.ts index b9a2051..7e9f56a 100644 --- a/deps.ts +++ b/deps.ts @@ -1,3 +1,3 @@ -export {dirname, fromFileUrl} from "https://deno.land/std@0.203.0/path/mod.ts"; -export {Logger, handlers} from "https://deno.land/std@0.203.0/log/mod.ts"; -export {format} from "https://deno.land/std@0.203.0/datetime/mod.ts"; \ No newline at end of file +export {dirname, fromFileUrl} from "https://deno.land/std@0.207.0/path/mod.ts"; +export {Logger, handlers} from "https://deno.land/std@0.207.0/log/mod.ts"; +export {format} from "https://deno.land/std@0.207.0/datetime/mod.ts"; \ No newline at end of file diff --git a/src/fetch.ts b/src/fetch.ts index 1e337ac..ec2af80 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -9,8 +9,10 @@ export interface FetchInit extends Omit{ body?: BodyInit; query?: URLSearchParams; secret?: { - token: string; - basic?: true; + key: string; + } | { + id: string; + pw: string; }; } @@ -49,13 +51,12 @@ export async function fetchExtend(path:string, typ } if(option?.secret){ - if(option.secret.basic){ - const [id, pw] = option.secret.token.split(/:/); - u.username = id ?? ""; - u.password = pw ?? ""; + if("key" in option.secret){ + h.set("Authorization", `Bearer ${option.secret.key}`); } else{ - h.set("Authorization", `Bearer ${option.secret.token}`); + u.username = option.secret.id; + u.password = option.secret.pw; } } diff --git a/test/fetch.test.ts b/test/fetch.test.ts index 0e70212..c88a476 100644 --- a/test/fetch.test.ts +++ b/test/fetch.test.ts @@ -13,7 +13,7 @@ Deno.test({ async fn(){ const ac = new AbortController(); - Deno.serve({ + const server = Deno.serve({ hostname: "127.0.0.1", port: 62000, signal: ac.signal @@ -24,5 +24,6 @@ Deno.test({ assertEquals(result, sample); ac.abort(); + await server.finished; } }); \ No newline at end of file