mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
fix(media): parse local file extensions across path styles (#105614)
* fix(media): parse local file extensions across path styles * docs: note cross-platform media path fix * docs: keep release notes in PR context --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
@@ -209,6 +209,8 @@ describe("getFileExtension", () => {
|
||||
{ filePath: "https://cdn.example.com/bad%ZZ%2Emp4", expected: undefined },
|
||||
{ filePath: "https://cdn.example.com/render%2Emp4/", expected: undefined },
|
||||
{ filePath: String.raw`C:\media\clip.MP4`, expected: ".mp4" },
|
||||
{ filePath: String.raw`C:\media.folder\clip`, expected: undefined },
|
||||
{ filePath: String.raw`C:\media.folder\clip.MP4`, expected: ".mp4" },
|
||||
] as const)("extracts $expected from $filePath", ({ filePath, expected }) => {
|
||||
expect(getFileExtension(filePath)).toBe(expected);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Media Core module implements mime behavior.
|
||||
import path from "node:path";
|
||||
import { type MediaKind, mediaKindFromMime } from "./constants.js";
|
||||
import { extnameFromAnyPath } from "./file-name.js";
|
||||
import { createLazyImportLoader } from "./lazy-import.js";
|
||||
|
||||
/** Maximum byte prefix passed to dependency MIME sniffers for bounded memory/CPU work. */
|
||||
@@ -157,7 +158,7 @@ export function getFileExtension(filePath?: string | null): string | undefined {
|
||||
} catch {
|
||||
// fall back to plain path parsing
|
||||
}
|
||||
const ext = path.extname(filePath).toLowerCase();
|
||||
const ext = extnameFromAnyPath(filePath).toLowerCase();
|
||||
return ext || undefined;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user