Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Server should not escape slashes in json responses.
Fixes issue #17
  • Loading branch information
bbrala committed Oct 26, 2018
commit acb0988b9ed29610f338dce4a59431a69d32281c
6 changes: 4 additions & 2 deletions src/Services/ResponseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ protected function createResponse($responseModel, $content)
if ($responseModel instanceof RespondError) {
$errors = $this->formatErrors($responseModel, $content);

return response()->json($errors, $responseModel->getStatusCode(), ['Content-Type' => 'application/vnd.api+json']);
return response()->json($errors, $responseModel->getStatusCode(), ['Content-Type' => 'application/vnd.api+json'], JSON_UNESCAPED_SLASHES);
}

return response()->json($content, $responseModel->getStatusCode(), ['Content-Type' => 'application/vnd.api+json']);
return response()->json($content, $responseModel->getStatusCode(), ['Content-Type' => 'application/vnd.api+json'], JSON_UNESCAPED_SLASHES);
}

public function respondWithResourceCollection($strResponseModel, $content)
Expand All @@ -33,6 +33,7 @@ public function respondWithResourceCollection($strResponseModel, $content)

return (new BaseApiCollectionResource($content))
->response()
->setEncodingOptions(JSON_UNESCAPED_SLASHES)
->header('Content-Type', 'application/vnd.api+json')
->setStatusCode($responseModel->getStatusCode());
}
Expand All @@ -46,6 +47,7 @@ public function responseWithResource($strResponseModel, $content)

return (new BaseApiResource($content))
->response()
->setEncodingOptions(JSON_UNESCAPED_SLASHES)
->header('Content-Type', 'application/vnd.api+json')
->setStatusCode($responseModel->getStatusCode());
}
Expand Down