@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.cjs CHANGED
@@ -958,12 +958,30 @@ function generateLrsBridgeCode(options) {
958
958
  });
959
959
  }
960
960
 
961
- // Decode HTML entities (e.g., " " & ') to clean text
961
+ // Clean HTML entities from text \u2014 handles both proper (") and broken (quot;) forms
962
+ // Rise strips the & from entities in SCORM interaction IDs, so we need both
962
963
  function decodeEntities(str) {
963
964
  if (!str || typeof str !== 'string') return str;
964
- var txt = document.createElement('textarea');
965
- txt.innerHTML = str;
966
- return txt.value;
965
+ // 1. Replace known broken entities (without &) that Rise leaves behind
966
+ str = str
967
+ .replace(/quot;/g, '"')
968
+ .replace(/apos;/g, "'")
969
+ .replace(/amp;/g, '&')
970
+ .replace(/lt;/g, '<')
971
+ .replace(/gt;/g, '>')
972
+ .replace(/nbsp;/g, ' ');
973
+ // 2. Replace numeric entities like &#34; &#39; &#x22; etc.
974
+ str = str.replace(/&#(x?[0-9a-fA-F]+);/g, function(match, code) {
975
+ var num = code.charAt(0) === 'x' ? parseInt(code.substring(1), 16) : parseInt(code, 10);
976
+ return isNaN(num) ? match : String.fromCharCode(num);
977
+ });
978
+ // 3. Catch any remaining standard &entities; via textarea decode
979
+ try {
980
+ var txt = document.createElement('textarea');
981
+ txt.innerHTML = str;
982
+ str = txt.value;
983
+ } catch (e) {}
984
+ return str;
967
985
  }
968
986
 
969
987
  LRS.sessionId = generateUUID();