Commit d4485c26 authored by Caleb Weeks's avatar Caleb Weeks

ignore .bl.json requests

parent e9d76a7e
......@@ -237,6 +237,7 @@ SC.getSling = async function(path, options = {}, callback){
const useGetIfExists =
sc_self.hasGetIfExistsCapability && //is the capability enabled
!options.dontParseBody && // dont use on requests that don't parse the body
!_.endsWith(path, '.bl.json') && //don't use on .bl.json requests
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){
......
......@@ -208,4 +208,18 @@ describe("get-if-exists", () => {
expect(request).toBeCalled();
expect(_.first(request.mock.calls)[0].uri).toMatch(/^.*fshr\/pages\/en.json$/);
});
test("Call getSling with get-if-exists (option) with .bl.json", async () => {
let clonedSc = sc.clone({hasGetIfExistsCapability: true});
try{
await clonedSc.getSling('/content/fshr/pages/en.bl.json', {useGetIfExists: 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.bl.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