Deep Link:
function generateDeepLink() {
const inputUrl = document.getElementById(‘affiliateUrl’).value.trim();
try {
const url = new URL(inputUrl);
// Validate it’s Amazon
if (!url.hostname.includes(‘amazon.’)) {
alert(‘Only Amazon links are supported right now.’);
return;
}
// Extract ASIN from URL
const asinMatch = inputUrl.match(/\/([A-Z0-9]{10})(?:[/?]|$)/i);
if (!asinMatch) {
alert(‘Could not extract ASIN from this URL.’);
return;
}
const asin = asinMatch[1];
// Generate deep link using app schema
const deepLink = `amazon://products/${asin}`;
document.getElementById(‘deepLinkResult’).value = deepLink;
} catch (e) {
alert(‘Invalid URL.’);
}
}
