Commit e9d76a7e authored by Caleb Weeks's avatar Caleb Weeks

don't use get if exists on request that don't parse

parent 27e029ba
......@@ -236,6 +236,7 @@ SC.getSling = async function(path, options = {}, callback){
// get if exists selector
const useGetIfExists =
sc_self.hasGetIfExistsCapability && //is the capability enabled
!options.dontParseBody && // dont use on requests that don't parse the body
path.match(/^\/?(content|etc)\/.*\.json$/) && // is this request a candidate (anything under content or etc that just ends with .json)
((sc_self.useGetIfExistsByDefault && !options.dontUseGetIfExists) || options.useGetIfExists); //and this request should use
if(useGetIfExists){
......
......@@ -193,5 +193,19 @@ describe("get-if-exists", () => {
expect(request).toBeCalled();
expect(_.first(request.mock.calls)[0].uri).toMatch(/^.*\.get-if-exists.foss-exists.json$/);
verififyNoDuplicate();
});
test("Call getSling with get-if-exists (option) with dontParseBody", async () => {
let clonedSc = sc.clone({hasGetIfExistsCapability: true});
try{
await clonedSc.getSling('/content/fshr/pages/en.json', {useGetIfExists: true, dontParseBody: true});
}catch(e){
//requesting an asset that doesn't have a mock will always throw an error.
expect(e).toBeTruthy();
}
expect(request).toBeCalled();
expect(_.first(request.mock.calls)[0].uri).toMatch(/^.*fshr\/pages\/en.json$/);
});
});
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment