⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ function getDefaultStyles(options: {
includeNone?: boolean;
cesdk?: CreativeEditorSDK;
}): Style[] {
// Normalize: strip trailing slashes to prevent double slashes in URL concatenation
const baseURL = options.baseURL.replace(/\/+$/, '');

return STYLES.map((style) => {
if (style.id === 'none') {
if (!options.includeNone) {
Expand All @@ -339,7 +342,7 @@ function getDefaultStyles(options: {
style.labelKey
),
prompt: style.prompt,
thumbUri: `${options.baseURL}/thumbnails/None.svg`
thumbUri: `${baseURL}/thumbnails/None.svg`
};
}
return {
Expand All @@ -350,7 +353,7 @@ function getDefaultStyles(options: {
style.labelKey
),
prompt: style.prompt,
thumbUri: `${options.baseURL}/thumbnails/${style.id}.jpeg`
thumbUri: `${baseURL}/thumbnails/${style.id}.jpeg`
};
}).filter(isDefined);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export const createStyleAssetSource = (
includeNone?: boolean;
}
) => {
// Normalize: strip trailing slashes to prevent double slashes in URL concatenation
const baseURL = options.baseURL.replace(/\/+$/, '');

const styleValues = STYLES.map((style) => {
if (style.id === 'none') {
if (!options.includeNone) {
Expand All @@ -101,13 +104,13 @@ export const createStyleAssetSource = (
return {
id: style.id,
label: style.label,
thumbUri: `${options.baseURL}/thumbnails/None.svg`
thumbUri: `${baseURL}/thumbnails/None.svg`
};
}
return {
id: style.id,
label: style.label,
thumbUri: `${options.baseURL}/thumbnails/${style.id}.jpeg`
thumbUri: `${baseURL}/thumbnails/${style.id}.jpeg`
};
}).filter(isDefined);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ const createStyleAssetSource = (
includeNone?: boolean;
}
) => {
// Normalize: strip trailing slashes to prevent double slashes in URL concatenation
const baseURL = options.baseURL.replace(/\/+$/, '');

const styleValues = STYLES.map((style) => {
if (style.id === 'none') {
if (!options.includeNone) {
Expand All @@ -135,13 +138,13 @@ const createStyleAssetSource = (
return {
id: style.id,
label: style.label,
thumbUri: `${options.baseURL}/thumbnails/None.svg`
thumbUri: `${baseURL}/thumbnails/None.svg`
};
}
return {
id: style.id,
label: style.label,
thumbUri: `${options.baseURL}/thumbnails/${style.id}.jpeg`
thumbUri: `${baseURL}/thumbnails/${style.id}.jpeg`
};
}).filter(isDefined);

Expand Down
8 changes: 6 additions & 2 deletions packages/plugin-cutout-library-web/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ function addCutoutAssetLibraryEntry(
cesdk: CreativeEditorSDK,
config: Partial<PluginConfiguration> = DEFAULT_PLUGIN_CONFIGURATION
) {
const { assetBaseUri } = getPluginConfiguration(config);
const { assetBaseUri: rawAssetBaseUri } = getPluginConfiguration(config);
// Normalize: strip trailing slashes to prevent double slashes in URL concatenation
const assetBaseUri = rawAssetBaseUri.replace(/\/+$/, '');
cesdk.ui.addAssetLibraryEntry({
id: ENTRY_ID,
sourceIds: [ASSET_SOURCE_ID],
Expand All @@ -72,13 +74,15 @@ function addCutoutAssetLibraryEntry(
async function addCutoutAssetSource(
cesdk: CreativeEditorSDK,
{
assetBaseUri,
assetBaseUri: rawAssetBaseUri,
createCutoutFromBlocks
}: {
assetBaseUri: string;
createCutoutFromBlocks: CreateCutoutFromBlocks;
}
) {
// Normalize: strip trailing slashes to prevent double slashes in URL concatenation
const assetBaseUri = rawAssetBaseUri.replace(/\/+$/, '');
const contentJSON = await fetch(
`${assetBaseUri}/${ASSET_SOURCE_ID}/content.json`
).then((res) => res.json());
Expand Down