From a7a2ac60e85fd03ebc80f5ba2b5a32fd2fbf8dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20R=C3=B6bert?= Date: Tue, 8 Aug 2017 23:34:56 +0200 Subject: [PATCH] URLs with completeProvider true are canceled --- clearurls.js | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/clearurls.js b/clearurls.js index f4de843..56f39f7 100644 --- a/clearurls.js +++ b/clearurls.js @@ -78,11 +78,12 @@ fetchFromURL(); * @param {String} _name Provider name * @param {boolean} completeProvider Set URL Pattern as rule */ -function Provider(_name,_completeProvider){ - var name = name; +function Provider(_name,_completeProvider = false){ + var name = _name; var urlPattern; var rules = new Array(); var exceptions = new Array(); + var canceling = _completeProvider; if(_completeProvider){ rules.push(".*"); @@ -97,6 +98,14 @@ function Provider(_name,_completeProvider){ 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. * @@ -171,6 +180,7 @@ function removeFieldsFormURL(provider, request) var url = request.url; var rules = provider.getRules(); var changes = false; + var cancel = false; if(provider.matchURL(url)) { @@ -184,11 +194,16 @@ function removeFieldsFormURL(provider, request) changes = true; } } + + if(provider.isCaneling()){ + cancel = true; + } } return { "changes": changes, - "url": url + "url": url, + "cancel": cancel } }; @@ -224,6 +239,15 @@ function clearUrl(request) for (var i = 0; i < providers.length; i++) { result = removeFieldsFormURL(providers[i], request); + /* + * Cancel the Request + */ + if(result["cancel"]){ + return { + cancel: true + } + } + /* * Ensure that the function go not into * an loop.