mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 12:54:29 +00:00
fix(studio): share safe media path cleanup
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
||||
} from "../../utils/studioPendingEdits";
|
||||
import type { DomEditSelection } from "./domEditing";
|
||||
import { ColorGradingControls } from "./propertyPanelColorGradingControls";
|
||||
import { stripQueryAndHash } from "./propertyPanelHelpers";
|
||||
import { Section } from "./propertyPanelPrimitives";
|
||||
|
||||
const COLOR_GRADING_DATA_KEY = HF_COLOR_GRADING_ATTR.replace(/^data-/, "");
|
||||
@@ -55,14 +56,6 @@ interface MediaMetadataResponse {
|
||||
metadata: MediaMetadata;
|
||||
}
|
||||
|
||||
function stripQueryAndHash(value: string): string {
|
||||
const queryIndex = value.indexOf("?");
|
||||
const hashIndex = value.indexOf("#");
|
||||
if (queryIndex < 0) return hashIndex < 0 ? value : value.slice(0, hashIndex);
|
||||
if (hashIndex < 0) return value.slice(0, queryIndex);
|
||||
return value.slice(0, Math.min(queryIndex, hashIndex));
|
||||
}
|
||||
|
||||
function stripPreviewAssetPath(src: string, projectId: string): string | null {
|
||||
let pathname = src;
|
||||
try {
|
||||
|
||||
@@ -10,6 +10,14 @@ export type {
|
||||
PropertyPanelProps,
|
||||
} from "./propertyPanelTypes";
|
||||
|
||||
export function stripQueryAndHash(value: string): string {
|
||||
const queryIndex = value.indexOf("?");
|
||||
const hashIndex = value.indexOf("#");
|
||||
if (queryIndex < 0) return hashIndex < 0 ? value : value.slice(0, hashIndex);
|
||||
if (hashIndex < 0) return value.slice(0, queryIndex);
|
||||
return value.slice(0, Math.min(queryIndex, hashIndex));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Font types & constants (shared by font and section modules) */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
LABEL,
|
||||
parseNumericValue,
|
||||
RESPONSIVE_GRID,
|
||||
stripQueryAndHash,
|
||||
} from "./propertyPanelHelpers";
|
||||
import { Section, SegmentedControl, SelectField, SliderControl } from "./propertyPanelPrimitives";
|
||||
|
||||
@@ -77,7 +78,7 @@ export function MediaSection({
|
||||
projectDir && srcAttr && !srcAttr.startsWith("http") ? `${projectDir}/${srcAttr}` : srcAttr;
|
||||
const projectSrc =
|
||||
srcAttr && !/^(?:https?:|data:|blob:)/i.test(srcAttr)
|
||||
? srcAttr.replace(/^\.\//, "").replace(/[?#].*$/, "")
|
||||
? stripQueryAndHash(srcAttr.startsWith("./") ? srcAttr.slice(2) : srcAttr)
|
||||
: "";
|
||||
const canRemoveBackground = Boolean(onRemoveBackground && isVisualMedia && projectSrc);
|
||||
const panelTitle = isImage ? "Image" : isVideo ? "Video" : "Audio";
|
||||
|
||||
Reference in New Issue
Block a user