@quik-fe/clear-urls
Version:
ClearURLs extension to js package.
251 lines (242 loc) • 7.4 kB
text/typescript
export declare function clearUrl(url: string, logger?: Logger): any;
/**
* Models a multimap backed by a {@link Set}.
*/
declare interface IMultimap<K, V> extends Iterable<[K, V]> {
_map: Map<K, Set<V>>;
_size: number;
get size(): number;
get(key: K): Set<V>;
put(key: K, value: V): boolean;
has(key: K): boolean;
hasEntry(key: K, value: V): boolean;
delete(key: K): boolean;
deleteEntry(key: K, value: V): boolean;
clear(): void;
entries(): IterableIterator<[K, V]>;
values(): IterableIterator<V>;
keys(): IterableIterator<K>;
forEach<T>(callback: (this: T | this, key: K, value: V, map: this) => void, thisArg?: T): void;
[Symbol.iterator](): IterableIterator<[K, V]>;
}
/**
* Models a hash parameter of a given {@link URL}.
*/
declare interface IURLHashParams {
_params: Multimap<any, any>;
append(name: string, value?: string | null): void;
delete(name: string): void;
get(name: string): string | null;
getAll(name: string): Set<string | null>;
keys(): IterableIterator<string>;
toString(): string;
}
export declare interface Logger extends Pick<Console, "info" | "log" | "warn" | "error"> {
}
/**
* Models a multimap backed by a {@link Set}.
*/
export declare class Multimap<K, V> implements IMultimap<K, V> {
_map: Map<K, Set<V>>;
_size: number;
constructor();
get size(): number;
get(key: K): Set<V>;
put(key: K, value: V): boolean;
has(key: K): boolean;
hasEntry(key: K, value: V): boolean;
delete(key: K): boolean;
deleteEntry(key: K, value: V): boolean;
clear(): void;
entries(): IterableIterator<[K, V]>;
values(): Generator<V, void, unknown>;
keys(): MapIterator<K>;
forEach(callback: Function, thisArg?: any): void;
[Symbol.iterator](): IterableIterator<[K, V]>;
}
export declare class Provider {
private _forceRedirection;
private name;
private urlPattern?;
private enabled_rules;
private disabled_rules;
private enabled_exceptions;
private disabled_exceptions;
private canceling;
private enabled_redirections;
private disabled_redirections;
private active;
private enabled_rawRules;
private disabled_rawRules;
private enabled_referralMarketing;
private disabled_referralMarketing;
private methods;
constructor(_name: string, _completeProvider?: boolean, _forceRedirection?: boolean, _isActive?: boolean);
/**
* Returns whether redirects should be enforced via a "tabs.update"
* @return {boolean} whether redirects should be enforced
*/
shouldForceRedirect(): boolean;
/**
* Returns the provider name.
* @return {String}
*/
getName(): string;
/**
* Add URL pattern.
*
* @require urlPatterns as RegExp
*/
setURLPattern(urlPatterns: string | RegExp): void;
/**
* Return if the Provider Request is canceled
* @return {Boolean} isCanceled
*/
isCaneling(): boolean;
/**
* Check the url is matching the ProviderURL.
*
* @return {boolean} ProviderURL as RegExp
*/
matchURL(url: string): boolean;
/**
* Apply a rule to a given tuple of rule array.
* @param enabledRuleArray array for enabled rules
* @param disabledRulesArray array for disabled rules
* @param {String} rule RegExp as string
* @param {boolean} isActive Is this rule active?
*/
private applyRule;
/**
* Add a rule to the rule array
* and replace old rule with new rule.
*
* @param {String} rule RegExp as string
* @param {boolean} isActive Is this rule active?
*/
addRule(rule: string, isActive?: boolean): void;
/**
* Return all active rules as an array.
*
* @return Array RegExp strings
*/
getRules(): string[];
/**
* Add a raw rule to the raw rule array
* and replace old raw rule with new raw rule.
*
* @param {String} rule RegExp as string
* @param {boolean} isActive Is this rule active?
*/
addRawRule(rule: string, isActive?: boolean): void;
/**
* Return all active raw rules as an array.
*
* @return Array RegExp strings
*/
getRawRules(): string[];
/**
* Add a referral marketing rule to the referral marketing array
* and replace old referral marketing rule with new referral marketing rule.
*
* @param {String} rule RegExp as string
* @param {boolean} isActive Is this rule active?
*/
addReferralMarketing(rule: string, isActive?: boolean): void;
/**
* Add a exception to the exceptions array
* and replace old with new exception.
*
* @param {String} exception RegExp as string
* @param {Boolean} isActive Is this exception active?
*/
addException(exception: string, isActive?: boolean): void;
/**
* Add a HTTP method to methods list.
*
* @param {String} method HTTP Method Name
*/
addMethod(method: string): void;
/**
* Check the requests' method.
*
* @param {requestDetails} details Requests details
* @returns {boolean} should be filtered or not
*/
matchMethod(details: {
[key: string]: string;
}): boolean;
/**
* Private helper method to check if the url
* an exception.
*
* @param {String} url RegExp as string
* @return {boolean} if matching? true: false
*/
private matchException;
/**
* Add a redirection to the redirections array
* and replace old with new redirection.
*
* @param {String} redirection RegExp as string
* @param {Boolean} isActive Is this redirection active?
*/
addRedirection(redirection: string, isActive?: boolean): void;
/**
* Return all redirection.
*
* @return url
*/
getRedirection(url: string): string | null;
}
/**
* Helper function which remove the tracking fields
* for each provider given as parameter.
*
* @param {Provider} provider Provider-Object
* @param pureUrl URL as String
* @param {boolean} quiet if the action should be displayed in log and statistics
* @return {Object} Array with changes and url fields
*/
export declare function removeFieldsFormURL({ provider, pureUrl, localHostsSkipping, domainBlocking, loggingStatus, logger, }: {
provider: Provider;
pureUrl: string;
localHostsSkipping?: boolean;
domainBlocking?: boolean;
loggingStatus?: boolean;
logger?: Logger;
}): {
changes: boolean;
url: string;
cancel: boolean;
redirect?: undefined;
} | {
redirect: boolean;
url: string;
changes?: undefined;
cancel?: undefined;
} | {
cancel: boolean;
url: string;
changes?: undefined;
redirect?: undefined;
} | {
changes: boolean;
url: string;
cancel?: undefined;
redirect?: undefined;
};
/**
* Models a hash parameter of a given {@link URL}.
*/
export declare class URLHashParams implements IURLHashParams {
_params: Multimap<any, any>;
constructor(url: URL);
append(name: any, value?: null): void;
delete(name: any): void;
get(name: any): any;
getAll(name: any): Set<any>;
keys(): MapIterator<any>;
toString(): string;
}
export { }