Skip to content

Commit

Permalink
fix type. (#83)
Browse files Browse the repository at this point in the history
* fix type.

* fix leaking resource.

* unused unstable method.
  • Loading branch information
dojyorin authored Nov 22, 2023
1 parent 3c24306 commit 9c19d20
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions deps.test.ts
Original file line number Diff line number Diff line change
@@ -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";
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";
6 changes: 3 additions & 3 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -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";
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";
15 changes: 8 additions & 7 deletions src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ export interface FetchInit extends Omit<RequestInit, "integrity" | "window">{
body?: BodyInit;
query?: URLSearchParams;
secret?: {
token: string;
basic?: true;
key: string;
} | {
id: string;
pw: string;
};
}

Expand Down Expand Up @@ -49,13 +51,12 @@ export async function fetchExtend<T extends keyof ResponseType>(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;
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,5 +24,6 @@ Deno.test({
assertEquals(result, sample);

ac.abort();
await server.finished;
}
});

0 comments on commit 9c19d20

Please sign in to comment.