Skip to content

Commit

Permalink
bug #1903 [LiveComponent] accept live component Content-Type with suf…
Browse files Browse the repository at this point in the history
…fix (WebMamba)

This PR was merged into the 2.x branch.

Discussion
----------

[LiveComponent] accept live component Content-Type with suffix

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| Issues        | Fix #1902
| License       | MIT

Commits
-------

044f338 [LiveComponent] accept live component Content-Type with suffix
  • Loading branch information
kbond committed Jun 11, 2024
2 parents fc8de45 + 044f338 commit 3b65275
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/LiveComponent/assets/dist/live_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2049,13 +2049,14 @@ class Component {
this.valueStore.flushDirtyPropsToPending();
this.isRequestPending = false;
this.backendRequest.promise.then(async (response) => {
var _a;
const backendResponse = new BackendResponse(response);
const html = await backendResponse.getBody();
for (const input of Object.values(this.pendingFiles)) {
input.value = '';
}
const headers = backendResponse.response.headers;
if (headers.get('Content-Type') !== 'application/vnd.live-component+html' && !headers.get('X-Live-Redirect')) {
if (!((_a = headers.get('Content-Type')) === null || _a === void 0 ? void 0 : _a.includes('application/vnd.live-component+html')) && !headers.get('X-Live-Redirect')) {
const controls = { displayError: true };
this.valueStore.pushPendingPropsBackToDirty();
this.hooks.triggerHook('response:error', backendResponse, controls);
Expand Down
2 changes: 1 addition & 1 deletion src/LiveComponent/assets/src/Component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export default class Component {

// if the response does not contain a component, render as an error
const headers = backendResponse.response.headers;
if (headers.get('Content-Type') !== 'application/vnd.live-component+html' && !headers.get('X-Live-Redirect')) {
if (!headers.get('Content-Type')?.includes('application/vnd.live-component+html') && !headers.get('X-Live-Redirect')) {
const controls = { displayError: true };
this.valueStore.pushPendingPropsBackToDirty();
this.hooks.triggerHook('response:error', backendResponse, controls);
Expand Down

0 comments on commit 3b65275

Please sign in to comment.