Found while fixing the same class on Facebook (#23, PR #45). Filing rather than widening that PR, since it is a different platform file.
src/platforms/instagram.js builds a usedVideoUrls Set and checks it on every video branch, so a repeated video is emitted once. The image loop just above it has no equivalent:
container.querySelectorAll('img[src*="cdninstagram.com"]').forEach((img) => {
const url = upgradeImageUrl(img.src, img);
if (url) {
items.push({ url, type: 'image', filename: shortcode ? `post_${shortcode}_${index}` : null });
index++;
}
});
Whether this actually duplicates depends on how much upgradeImageUrl normalizes. On Facebook the equivalent function strips the size segment from the CDN path, which is what turns two src values for one carousel slide into one identical URL, so the missing dedupe does not merely permit duplicates, it produces them. Someone should check whether upgradeImageUrl collapses Instagram's size variants the same way before assuming this is or is not live. That check is the first task here, not the fix.
If it does duplicate, the symptom matches Facebook's: the _${index} suffix gives each copy a distinct filename, so one photo saved twice reads as a two-photo carousel rather than as a bug.
Worth deciding at the same time whether the dedupe belongs in each platform file or in common.js. Three platforms now walk a container for CDN images and number the results, and the tie-break is not always the same: document order wants the first sighting kept, and a recency-ordered capture list wants the last.
Found while fixing the same class on Facebook (#23, PR #45). Filing rather than widening that PR, since it is a different platform file.
src/platforms/instagram.jsbuilds ausedVideoUrlsSet and checks it on every video branch, so a repeated video is emitted once. The image loop just above it has no equivalent:Whether this actually duplicates depends on how much
upgradeImageUrlnormalizes. On Facebook the equivalent function strips the size segment from the CDN path, which is what turns twosrcvalues for one carousel slide into one identical URL, so the missing dedupe does not merely permit duplicates, it produces them. Someone should check whetherupgradeImageUrlcollapses Instagram's size variants the same way before assuming this is or is not live. That check is the first task here, not the fix.If it does duplicate, the symptom matches Facebook's: the
_${index}suffix gives each copy a distinct filename, so one photo saved twice reads as a two-photo carousel rather than as a bug.Worth deciding at the same time whether the dedupe belongs in each platform file or in
common.js. Three platforms now walk a container for CDN images and number the results, and the tie-break is not always the same: document order wants the first sighting kept, and a recency-ordered capture list wants the last.