mirror of
https://github.com/ClearURLs/Addon.git
synced 2024-10-03 22:58:10 +03:00
Added recursive cleaning
+ Added recursive cleaning
This commit is contained in:
parent
f8d2852e71
commit
b2a9333611
@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Added Indonesian translation by Iputucaganesha
|
||||
- Added `content_security_policy` to `manifest.json`
|
||||
- Re-Added `applications`to `manifest.json`
|
||||
- Added recursive cleaning
|
||||
|
||||
### Changed
|
||||
- Updated `homepage_url` and `author` field in `manifest.json`
|
||||
|
@ -19,17 +19,32 @@
|
||||
/*jshint esversion: 6 */
|
||||
|
||||
/**
|
||||
* Cleans given links. Also do automatic redirection.
|
||||
* Cleans given URLs. Also do automatic redirection.
|
||||
*
|
||||
* @param {String} url url as string
|
||||
* @param {boolean} quiet if the action should be displayed in log and statistics
|
||||
* @return {String} redirectUrl or none
|
||||
* @return {String} cleaned URL
|
||||
*/
|
||||
function pureCleaning(url, quiet = false) {
|
||||
let before = url;
|
||||
let after = url;
|
||||
|
||||
do {
|
||||
before = after;
|
||||
after = _cleaning(before, quiet);
|
||||
} while (after !== before); // do recursive cleaning
|
||||
|
||||
return after;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function to clean the given URL.
|
||||
*/
|
||||
function _cleaning(url, quiet = false) {
|
||||
let cleanURL = url;
|
||||
const URLbeforeReplaceCount = countFields(url);
|
||||
|
||||
if(!quiet) {
|
||||
if (!quiet) {
|
||||
//Add Fields form Request to global url counter
|
||||
increaseGlobalURLCounter(URLbeforeReplaceCount);
|
||||
}
|
||||
@ -42,14 +57,12 @@ function pureCleaning(url, quiet = false) {
|
||||
"cancel": false
|
||||
};
|
||||
|
||||
if(providers[i].matchURL(cleanURL))
|
||||
{
|
||||
if (providers[i].matchURL(cleanURL)) {
|
||||
result = removeFieldsFormURL(providers[i], cleanURL, quiet);
|
||||
cleanURL = result.url;
|
||||
}
|
||||
|
||||
if(result.redirect)
|
||||
{
|
||||
if (result.redirect) {
|
||||
return result.url;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user