Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions deno/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ export async function shortHash(fileName: string): Promise<string> {
count++;
}

const parts = splitOnce(sub, ".", "right");
sub = parts[0];
let ext = parts.at(1);
sub = splitOnce(sub, ".", "right")[0];
let ext = splitOnce(fileName, ".", "right").at(1);
ext = ext ? `.${ext}` : "";

if (sub.length === 0) {
Expand Down
6 changes: 5 additions & 1 deletion deno/tests/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ Deno.test("shortHash returns hashed filename for forbidden/long names", async ()
const result = await shortHash("ThisIsUppercase.txt");
assertMatch(result, /^#thisisuppercase_[a-f0-9]{5}\.txt$/);
const result2 = await shortHash("file?name.txt");
assertMatch(result2, /^#file_[a-f0-9]{5}$/);
assertMatch(result2, /^#file_[a-f0-9]{5}.txt$/);
const result3 = await shortHash("a".repeat(40));
assertMatch(result3, /^#aaaaaaaaaaaaaaaaaaaa_[a-f0-9]{5}$/);
const result4 = await shortHash("file<name.ts");
assertMatch(result4, /^#file_name_[a-f0-9]{5}.ts$/);
const result5 = await shortHash(
"unstable_get_network_address.ts",
);
assertEquals(result5, "#unstable_get_network_b61b7.ts");
});

Deno.test("shortHash returns hashed filename for empty string", async () => {
Expand Down