Skip to content

Commit be5e333

Browse files
committed
Enhance entity ID extraction in ThumbPreviews plugin to strip URL parameters for cleaner data handling.
1 parent 6ddad55 commit be5e333

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

plugins/ThumbPreviews/ThumbPreviews.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,16 @@
7575
existingImage.style.opacity = '1'; // Ensure initial opacity is 1
7676

7777
// Extract Entity ID from the card.
78-
const entityId = cardElement.dataset.entityId || cardElement.querySelector(`a[href^="${currentConfig.urlPattern}"]`)?.href.match(new RegExp(`${currentConfig.urlPattern.replace('/', '\\/')}([^\\/]+)`))?.[1];
78+
let entityId = cardElement.dataset.entityId || cardElement.querySelector(`a[href^="${currentConfig.urlPattern}"]`)?.href.match(new RegExp(`${currentConfig.urlPattern.replace('/', '\\/')}([^\\/]+)`))?.[1];
79+
80+
// Ensure only the numerical ID is captured, removing any URL parameters
81+
if (entityId) {
82+
const paramIndex = entityId.indexOf('?');
83+
if (paramIndex !== -1) {
84+
entityId = entityId.substring(0, paramIndex);
85+
// console.log(`Stripped parameters from entityId: ${entityId}`);
86+
}
87+
}
7988

8089
if (!entityId) {
8190
// console.warn(`${entityType} ID not found for card:`, cardElement);

0 commit comments

Comments
 (0)