Skip to content

Commit 33c6d76

Browse files
Update index.js
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 093c1cd commit 33c6d76

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,19 @@ export class Placement {
537537
const style = element.getAttribute(ATTR_PREFIX + "style");
538538
const force_ad = element.getAttribute(ATTR_PREFIX + "force-ad");
539539
const force_campaign = element.getAttribute(ATTR_PREFIX + "force-campaign");
540-
const priority = element.getAttribute(ATTR_PREFIX + "priority");
540+
const priorityAttr = element.getAttribute(ATTR_PREFIX + "priority");
541+
let priority;
542+
if (priorityAttr !== null && priorityAttr !== "") {
543+
const parsedPriority = parseInt(priorityAttr, 10);
544+
if (!Number.isNaN(parsedPriority)) {
545+
priority = parsedPriority;
546+
} else {
547+
logger.warn(
548+
"EthicalAd: Invalid numerical priority '%s' provided; ignoring.",
549+
priorityAttr
550+
);
551+
}
552+
}
541553

542554
// Add version to ad type to verison the HTML return
543555
if (ad_type === "image" || ad_type === "text") {

0 commit comments

Comments
 (0)