@hyperbook/markdown 0.59.1 → 0.59.2

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.
@@ -4,8 +4,17 @@
4
4
  * Blockflow editor client script.
5
5
  * Prepends window.origin to relative project URLs so that
6
6
  * blockflow.openpatch.org can fetch them cross-origin.
7
+ *
8
+ * The ?project= parameter accepts:
9
+ * - A base64-encoded JSON string (no origin prepended)
10
+ * - A URL to a .json project file (origin prepended if relative)
11
+ * - A URL to an .sb3 Scratch project (origin prepended if relative)
7
12
  */
8
13
  (function () {
14
+ function isRelativeUrl(value) {
15
+ return /\.(json|sb3)($|\?)/.test(value) || value.startsWith("/");
16
+ }
17
+
9
18
  function fixIframes(root) {
10
19
  var iframes = root.querySelectorAll
11
20
  ? root.querySelectorAll(".directive-blockflow-editor iframe")
@@ -16,7 +25,7 @@
16
25
  try {
17
26
  var url = new URL(src);
18
27
  var project = url.searchParams.get("project");
19
- if (project && !project.match(/^https?:\/\//)) {
28
+ if (project && !project.match(/^https?:\/\//) && isRelativeUrl(project)) {
20
29
  url.searchParams.set("project", window.origin + project);
21
30
  iframe.setAttribute("src", url.toString());
22
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperbook/markdown",
3
- "version": "0.59.1",
3
+ "version": "0.59.2",
4
4
  "author": "Mike Barkmin",
5
5
  "homepage": "https://github.com/openpatch/hyperbook#readme",
6
6
  "license": "MIT",