feat: add Adsterra link conversion
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
const base = withoutHash.slice(0, queryIndex);
|
||||
const query = withoutHash.slice(queryIndex + 1);
|
||||
const replacements = { platform: template.platformCode, ...linkTemplate.mappings };
|
||||
const removedParams = new Set(linkTemplate.removeParams || []);
|
||||
const changes = [];
|
||||
let parameterCount = 0;
|
||||
|
||||
@@ -39,12 +40,16 @@
|
||||
const rawKey = equalIndex >= 0 ? segment.slice(0, equalIndex) : segment;
|
||||
const rawValue = equalIndex >= 0 ? segment.slice(equalIndex + 1) : '';
|
||||
const key = decodeKey(rawKey);
|
||||
if (removedParams.has(key)) {
|
||||
changes.push({ key, from:rawValue, to:'', removed:true });
|
||||
return null;
|
||||
}
|
||||
if (!Object.prototype.hasOwnProperty.call(replacements, key)) return segment;
|
||||
|
||||
const replacement = String(replacements[key] ?? '');
|
||||
if (rawValue !== replacement) changes.push({ key, from: rawValue, to: replacement });
|
||||
if (rawValue !== replacement) changes.push({ key, from: rawValue, to: replacement, removed:false });
|
||||
return `${rawKey}=${replacement}`;
|
||||
});
|
||||
}).filter((segment) => segment !== null);
|
||||
|
||||
return {
|
||||
url: `${base}?${convertedSegments.join('&')}${hash}`,
|
||||
|
||||
Reference in New Issue
Block a user