Skip to content
Open
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
16 changes: 12 additions & 4 deletions src/loading-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
* @return {Boolean} retrns true if cached, otherwise false
*/
function isCached(config) {
var cache;
var defaultCache = $cacheFactory.get('$http');
var defaults = $httpProvider.defaults;
var cache,
defaultCache = $cacheFactory.get('$http'),
defaults = $httpProvider.defaults,
url = buildUrl(config.url, config.paramSerializer(config.params));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single variable declaration per line please


// Choose the proper cache source. Borrowed from angular: $http service
if ((config.cache || defaults.cache) && config.cache !== false &&
Expand All @@ -79,7 +80,7 @@ angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
}

var cached = cache !== undefined ?
cache.get(config.url) !== undefined : false;
cache.get(url) !== undefined : false;

if (config.cached !== undefined && cached !== config.cached) {
return config.cached;
Expand All @@ -88,6 +89,13 @@ angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
return cached;
}

function buildUrl(url, serializedParams) {
if (serializedParams.length > 0) {
url += ((url.indexOf('?') == -1) ? '?' : '&') + serializedParams;
}
return url;
}


return {
'request': function(config) {
Expand Down