Skip to content

Commit

Permalink
Update default Content-Type to reflect the one used by cable_ready
Browse files Browse the repository at this point in the history
Since stimulusreflex/cable_ready#260, `cable_ready` changed its Content-Type to `text/vnd.cable-ready.json`.
This commit updates the default one used to be compatible with `cable_ready`.
  • Loading branch information
jibees committed Mar 30, 2023
1 parent 86ec3dd commit a6ddedc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/src/_documentation/how_tos/05-integrate-cablecar.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ mrujs.start({
Now, any link or form with `data-method="<method>"` or `data-remote="true"` will have the following `Accept` header:

```js
"application/vnd.cable-ready.json, */*"
"text/vnd.cable-ready.json, */*"
```

which means any link or form with `data-method="<method>"` or `data-remote="true"` will
perform an AJAX request, return JSON if it finds a CableCar response from your Rails
server (or any Ruby server which provides a `Content-Type: application/vnd.cable-ready.json`
server (or any Ruby server which provides a `Content-Type: text/vnd.cable-ready.json`
header), and then automatically perform CableCar operations defined in the JSON payload
return.

Expand Down
2 changes: 1 addition & 1 deletion plugins/src/cableCar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class CableCar {

constructor (cableReady: CableReady, { mimeType }: CableCarConfig = {}) {
this.cableReady = cableReady
this.mimeType = (mimeType ?? 'application/vnd.cable-ready.json')
this.mimeType = mimeType ?? "text/vnd.cable-ready.json";
this.boundPerform = this.perform.bind(this) as EventListener
}

Expand Down
2 changes: 1 addition & 1 deletion test/js/plugins/cableCar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('CableCar with standard config', () => {
})

it('Should return true for the given content type', () => {
assert(cableCar.isCableReadyResponse("application/vnd.cable-ready.json; charset='utf-8'"))
assert(cableCar.isCableReadyResponse("text/vnd.cable-ready.json; charset='utf-8'"))
})

it('Should return true for the given content type', () => {
Expand Down

0 comments on commit a6ddedc

Please sign in to comment.