Closed bahadirbb closed 9 years ago
Could you explain the need for this a bit more and add some passing unit tests?
sure, urlMustContain parameter is for filtering batch requests. For example my angularjs application tries to load templates dynamically as it is required. batcher tries to make a batch request for html files which are static. so server side cant find required controllers for these static files. by adding urlMustContain property, i am saying: only try to batch load requests which has at least one of these keywords in its url. by doing this i prevent trying to load static files by batch request. only batch load requests which contain "api" in its url.
this has some issues though. a static file may have "api" keyword in it's name. maybe we should change this to check start of url. like url should start with "/api" keyword.
i added allowRelativeURL property to support relative URL's as i inspected source code i saw that requests which dont have absolute url's aren't batched at all. because batchConfig was looking for an absolute url match to find necessary config file.
i may be wrong. i couldn't inspect source code completely. if i make sense to you i will add unit tests asap
I'm trying to think of a more generic way of handling this. I don't really want to go down the route of adding magic properties to do things and having done this lots in the past and coming back to the code I always forget what those magic properties do. I think it might be better if I provide a function that the implementer can pass into the options to do their own inspection of the urls to determine if it can be batched. Something like a match function?
yep you are right, i ll try to submit that match function. i dont have much time this week but i ll try to create some
With urlMustContain property one can allow batching of some requests. which goes to a particular endpoint. allowRelativeURL property removes the need for absolute url match while searching for a config