@patch-adams/core 1.5.8 → 1.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -948,12 +948,30 @@ function generateLrsBridgeCode(options) {
948
948
  });
949
949
  }
950
950
 
951
- // Decode HTML entities (e.g., " " & ') to clean text
951
+ // Clean HTML entities from text \u2014 handles both proper (") and broken (quot;) forms
952
+ // Rise strips the & from entities in SCORM interaction IDs, so we need both
952
953
  function decodeEntities(str) {
953
954
  if (!str || typeof str !== 'string') return str;
954
- var txt = document.createElement('textarea');
955
- txt.innerHTML = str;
956
- return txt.value;
955
+ // 1. Replace known broken entities (without &) that Rise leaves behind
956
+ str = str
957
+ .replace(/quot;/g, '"')
958
+ .replace(/apos;/g, "'")
959
+ .replace(/amp;/g, '&')
960
+ .replace(/lt;/g, '<')
961
+ .replace(/gt;/g, '>')
962
+ .replace(/nbsp;/g, ' ');
963
+ // 2. Replace numeric entities like &#34; &#39; &#x22; etc.
964
+ str = str.replace(/&#(x?[0-9a-fA-F]+);/g, function(match, code) {
965
+ var num = code.charAt(0) === 'x' ? parseInt(code.substring(1), 16) : parseInt(code, 10);
966
+ return isNaN(num) ? match : String.fromCharCode(num);
967
+ });
968
+ // 3. Catch any remaining standard &entities; via textarea decode
969
+ try {
970
+ var txt = document.createElement('textarea');
971
+ txt.innerHTML = str;
972
+ str = txt.value;
973
+ } catch (e) {}
974
+ return str;
957
975
  }
958
976
 
959
977
  LRS.sessionId = generateUUID();