feat: add Adsterra link conversion

This commit is contained in:
王源
2026-10-20 18:39:37 +08:00
parent 704df02775
commit f486d3454d
7 changed files with 61 additions and 13 deletions
+7 -2
View File
@@ -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}`,