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
11 changes: 11 additions & 0 deletions src/confighttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,17 @@ namespace confighttp {
input_tree.erase("detached");
}

std::string image_path;
if (input_tree.contains("image-path") && input_tree["image-path"].is_string()) {
image_path = input_tree["image-path"].get<std::string>();
}
boost::trim(image_path);
if (image_path.empty()) {
input_tree.erase("image-path");
} else {
input_tree["image-path"] = image_path;
}

auto &apps_node = file_tree["apps"];
int index = input_tree["index"].get<int>(); // this will intentionally cause an exception if the provided value is the wrong type

Expand Down
7 changes: 5 additions & 2 deletions src_assets/common/assets/web/Apps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1024,10 +1024,13 @@
},
save() {
this.editFormError = "";
this.editForm["image-path"] = this.editForm["image-path"].toString().replaceAll('"', '');
const currentImagePath = this.editForm["image-path"] == null ? "" : String(this.editForm["image-path"]).trim();
this.editForm["image-path"] = currentImagePath.replaceAll('"', '');

const imagePath = this.editForm["image-path"];
if (imagePath && !imagePath.toLowerCase().endsWith('.png')) {
if (!imagePath) {
delete this.editForm["image-path"];
} else if (!imagePath.toLowerCase().endsWith('.png')) {
this.editFormError = this.$t('file_browser.error_invalid_extension', { extensions: '.png' });
const modalBody = this.$refs.editModal.querySelector('.modal-body');
if (modalBody) modalBody.scrollTop = 0;
Expand Down
13 changes: 12 additions & 1 deletion tests/web/Apps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,23 @@ describe('save – cover image validation', () => {
)
})

it('submits when the image path is empty', () => {
it('submits when the image path is empty and leaves the letter cover as the default', () => {
const ctx = saveContext('')

Apps.methods.save.call(ctx)

expect(ctx.editFormError).toBe('')
expect(ctx.editForm['image-path']).toBeUndefined()
expect(apiFetch).toHaveBeenCalledOnce()
})

it('submits when the image path is missing', () => {
const ctx = saveContext(null)

expect(() => Apps.methods.save.call(ctx)).not.toThrow()

expect(ctx.editFormError).toBe('')
expect(ctx.editForm['image-path']).toBeUndefined()
expect(apiFetch).toHaveBeenCalledOnce()
})

Expand Down