Skip to content

Commit

Permalink
Fix incorrect extension extraction from file paths
Browse files Browse the repository at this point in the history
Fixes #1029

Our extension extraction logic was taking into account folder names, which can include periods. The logic would incorrectly identify a file path of `.well-known/foo` as having the extension of `well-known/foo` when in reality it should be an empty string.
  • Loading branch information
jrf0110 committed May 17, 2022
1 parent cc6e18b commit d679919
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/wrangler/src/pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { execSync, spawn } from "node:child_process";
import { existsSync, lstatSync, readFileSync, writeFileSync } from "node:fs";
import { readdir, readFile, stat } from "node:fs/promises";
import { tmpdir } from "node:os";
import { dirname, join, sep } from "node:path";
import { dirname, join, sep, extname, basename } from "node:path";
import { cwd } from "node:process";
import { URL } from "node:url";
import { hash } from "blake3-wasm";
Expand Down Expand Up @@ -1079,8 +1079,7 @@ const createDeployment: CommandModule<
const fileContent = await readFile(filepath);

const base64Content = fileContent.toString("base64");
const extension =
name.split(".").length > 1 ? name.split(".").at(-1) || "" : "";
const extension = extname(basename(name)).substring(1);

const content = base64Content + extension;

Expand Down

0 comments on commit d679919

Please sign in to comment.