Skip to content
Open
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
14 changes: 12 additions & 2 deletions packages/decap-cms-core/src/reducers/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ let slug: string;

const storageSortKey = 'decap-cms.entries.sort';
const viewStyleKey = 'decap-cms.entries.viewStyle';

function normalizeDoubleSlashes(path: string) {
if (!path) {
return path;
}

return path.replace(/([^:]\/)\/+/g, '$1');
}
type StorageSortObject = SortObject & { index: number };
type StorageSort = { [collection: string]: { [key: string]: StorageSortObject } };

Expand Down Expand Up @@ -785,12 +793,14 @@ export function selectMediaFilePublicPath(
}

const name = 'public_folder';
let publicFolder = config[name]!;
let publicFolder = normalizeDoubleSlashes(config[name]!);

const customFolder = hasCustomFolder(name, collection, entryMap?.get('slug'), field);

if (customFolder) {
publicFolder = evaluateFolder(name, config, collection!, entryMap, field);
publicFolder = normalizeDoubleSlashes(
evaluateFolder(name, config, collection!, entryMap, field),
);
}

if (isAbsolutePath(publicFolder)) {
Expand Down
5 changes: 3 additions & 2 deletions packages/decap-cms-lib-util/src/path.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const absolutePath = new RegExp('^(?:[a-z]+:)?//', 'i');
const absolutePath = new RegExp('^(?:[a-z]+:)?//|^/', 'i');

function normalizePath(path: string) {
return path.replace(/[\\/]+/g, '/');
}

export function isAbsolutePath(path: string) {
return absolutePath.test(path);
const result = absolutePath.test(path);
return result;
}

/**
Expand Down
Loading