Skip to content

Commit 1e1c7a7

Browse files
authored
refactor(http): reached full line coverage, unwind ternary to improve reability (#6885)
1 parent 7e8c8d2 commit 1e1c7a7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

http/etag.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ export async function eTag(
158158
? calcFileInfo(entity, options)
159159
: calcEntity(entity, options));
160160

161-
return tag ? weak ? `W/"${tag}"` : `"${tag}"` : undefined;
161+
if (!tag) {
162+
return undefined;
163+
}
164+
165+
return weak ? `W/"${tag}"` : `"${tag}"`;
162166
}
163167

164168
const STAR_REGEXP = /^\s*\*\s*$/;

http/etag_test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,17 @@ Deno.test({
147147
}
148148
},
149149
});
150+
151+
Deno.test({
152+
name: "eTag() returns undefined when calcFileInfo returns undefined",
153+
async fn() {
154+
{
155+
const result = await eTag({
156+
mtime: null,
157+
size: 1024,
158+
});
159+
160+
assert(result === undefined);
161+
}
162+
},
163+
});

0 commit comments

Comments
 (0)