From 87ed920dc181eb622afd9c1b81c3ee80ec5c94f8 Mon Sep 17 00:00:00 2001 From: AppleL <2265072+aplhk@users.noreply.github.com> Date: Sun, 13 Nov 2022 18:55:38 +0800 Subject: [PATCH] Add hasOwnProperty checks to metadata setters --- src/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 8f8082eb..5893dacb 100644 --- a/src/index.js +++ b/src/index.js @@ -1150,7 +1150,9 @@ let Amplitude = (function() { for (var key in metaData) { if (metaData.hasOwnProperty(key)) { if (key != "url" && key != "URL" && key != "live" && key != "LIVE") { - config.playlists[playlist].songs[index][key] = metaData[key]; + if (config.playlists[playlist].songs.hasOwnProperty(index)) { + config.playlists[playlist].songs[index][key] = metaData[key]; + } } } } @@ -1161,7 +1163,9 @@ let Amplitude = (function() { for (var key in metaData) { if (metaData.hasOwnProperty(key)) { if (key != "url" && key != "URL" && key != "live" && key != "LIVE") { - config.songs[index][key] = metaData[key]; + if (config.songs.hasOwnProperty(index)) { + config.songs[index][key] = metaData[key]; + } } } } @@ -1185,7 +1189,9 @@ let Amplitude = (function() { for (var key in metaData) { if (metaData.hasOwnProperty(key)) { if (ignoredKeys.indexOf(key) < 0) { - config.playlists[playlist][key] = metaData[key]; + if (config.playlists.hasOwnProperty(playlist)) { + config.playlists[playlist][key] = metaData[key]; + } } } }