fix(config): allow empty public folder for collection,file,field (#5391)
This commit is contained in:
parent
f0725a8379
commit
558b21f700
@ -214,7 +214,7 @@ describe('config', () => {
|
|||||||
).toEqual('static/images/docs');
|
).toEqual('static/images/docs');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not overwrite collection public_folder if set', () => {
|
it('should not overwrite collection public_folder if set to non empty string', () => {
|
||||||
expect(
|
expect(
|
||||||
applyDefaults({
|
applyDefaults({
|
||||||
collections: [
|
collections: [
|
||||||
@ -229,6 +229,21 @@ describe('config', () => {
|
|||||||
).toEqual('images/docs');
|
).toEqual('images/docs');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not overwrite collection public_folder if set to empty string', () => {
|
||||||
|
expect(
|
||||||
|
applyDefaults({
|
||||||
|
collections: [
|
||||||
|
{
|
||||||
|
folder: 'foo',
|
||||||
|
media_folder: 'static/images/docs',
|
||||||
|
public_folder: '',
|
||||||
|
fields: [{ name: 'title', widget: 'string' }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}).collections[0].public_folder,
|
||||||
|
).toEqual('');
|
||||||
|
});
|
||||||
|
|
||||||
it("should set collection media_folder and public_folder to an empty string when collection path exists, but collection media_folder doesn't", () => {
|
it("should set collection media_folder and public_folder to an empty string when collection path exists, but collection media_folder doesn't", () => {
|
||||||
const result = applyDefaults({
|
const result = applyDefaults({
|
||||||
collections: [
|
collections: [
|
||||||
|
@ -69,7 +69,7 @@ function getConfigUrl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setDefaultPublicFolderForField<T extends CmsField>(field: T) {
|
function setDefaultPublicFolderForField<T extends CmsField>(field: T) {
|
||||||
if ('media_folder' in field && !field.public_folder) {
|
if ('media_folder' in field && !('public_folder' in field)) {
|
||||||
return { ...field, public_folder: field.media_folder };
|
return { ...field, public_folder: field.media_folder };
|
||||||
}
|
}
|
||||||
return field;
|
return field;
|
||||||
@ -271,7 +271,7 @@ export function applyDefaults(originalConfig: CmsConfig) {
|
|||||||
collection.media_folder = '';
|
collection.media_folder = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('media_folder' in collection && !collection.public_folder) {
|
if ('media_folder' in collection && !('public_folder' in collection)) {
|
||||||
collection.public_folder = collection.media_folder;
|
collection.public_folder = collection.media_folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ export function applyDefaults(originalConfig: CmsConfig) {
|
|||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
file.file = trimStart(file.file, '/');
|
file.file = trimStart(file.file, '/');
|
||||||
|
|
||||||
if ('media_folder' in file && !file.public_folder) {
|
if ('media_folder' in file && !('public_folder' in file)) {
|
||||||
file.public_folder = file.media_folder;
|
file.public_folder = file.media_folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user