URLs with completeProvider true are canceled

This commit is contained in:
Kevin Röbert 2017-08-08 23:34:56 +02:00
parent 9a0ca8391b
commit a7a2ac60e8

View File

@ -78,11 +78,12 @@ fetchFromURL();
* @param {String} _name Provider name * @param {String} _name Provider name
* @param {boolean} completeProvider Set URL Pattern as rule * @param {boolean} completeProvider Set URL Pattern as rule
*/ */
function Provider(_name,_completeProvider){ function Provider(_name,_completeProvider = false){
var name = name; var name = _name;
var urlPattern; var urlPattern;
var rules = new Array(); var rules = new Array();
var exceptions = new Array(); var exceptions = new Array();
var canceling = _completeProvider;
if(_completeProvider){ if(_completeProvider){
rules.push(".*"); rules.push(".*");
@ -97,6 +98,14 @@ function Provider(_name,_completeProvider){
urlPattern = new RegExp(urlPatterns, "mgi"); urlPattern = new RegExp(urlPatterns, "mgi");
}; };
/**
* Return if the Provider Request is canceled
* @return {Boolean} isCanceled
*/
this.isCaneling = function() {
return canceling;
};
/** /**
* Check the url is matching the ProviderURL. * Check the url is matching the ProviderURL.
* *
@ -171,6 +180,7 @@ function removeFieldsFormURL(provider, request)
var url = request.url; var url = request.url;
var rules = provider.getRules(); var rules = provider.getRules();
var changes = false; var changes = false;
var cancel = false;
if(provider.matchURL(url)) if(provider.matchURL(url))
{ {
@ -184,11 +194,16 @@ function removeFieldsFormURL(provider, request)
changes = true; changes = true;
} }
} }
if(provider.isCaneling()){
cancel = true;
}
} }
return { return {
"changes": changes, "changes": changes,
"url": url "url": url,
"cancel": cancel
} }
}; };
@ -224,6 +239,15 @@ function clearUrl(request)
for (var i = 0; i < providers.length; i++) { for (var i = 0; i < providers.length; i++) {
result = removeFieldsFormURL(providers[i], request); result = removeFieldsFormURL(providers[i], request);
/*
* Cancel the Request
*/
if(result["cancel"]){
return {
cancel: true
}
}
/* /*
* Ensure that the function go not into * Ensure that the function go not into
* an loop. * an loop.