@medialane/ui 0.125.2 → 0.125.3
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/utils/ipfs.cjs +2 -6
- package/dist/utils/ipfs.cjs.map +1 -1
- package/dist/utils/ipfs.js +2 -6
- package/dist/utils/ipfs.js.map +1 -1
- package/package.json +1 -1
package/dist/utils/ipfs.cjs
CHANGED
|
@@ -21,15 +21,14 @@ __export(ipfs_exports, {
|
|
|
21
21
|
ipfsToHttp: () => ipfsToHttp
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(ipfs_exports);
|
|
24
|
-
const
|
|
25
|
-
const DEFAULT_GATEWAY = `${MEDIA_BASE_URL}/media/ipfs/`;
|
|
24
|
+
const DEFAULT_GATEWAY = "/api/ipfs/";
|
|
26
25
|
const ALLOWED_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "ipfs:"]);
|
|
27
26
|
function ipfsToHttp(uri, gateway = DEFAULT_GATEWAY) {
|
|
28
27
|
if (!uri) return "";
|
|
29
28
|
if (uri.startsWith("ipfs://")) {
|
|
30
29
|
return uri.replace("ipfs://", gateway);
|
|
31
30
|
}
|
|
32
|
-
if (uri.startsWith(
|
|
31
|
+
if (uri.startsWith("data:image/")) {
|
|
33
32
|
return uri;
|
|
34
33
|
}
|
|
35
34
|
try {
|
|
@@ -38,9 +37,6 @@ function ipfsToHttp(uri, gateway = DEFAULT_GATEWAY) {
|
|
|
38
37
|
} catch {
|
|
39
38
|
return "";
|
|
40
39
|
}
|
|
41
|
-
if (uri.startsWith("https://") || uri.startsWith("http://")) {
|
|
42
|
-
return `${MEDIA_BASE_URL}/media/external?url=${encodeURIComponent(uri)}`;
|
|
43
|
-
}
|
|
44
40
|
return uri;
|
|
45
41
|
}
|
|
46
42
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/utils/ipfs.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/ipfs.ts"],"sourcesContent":["const
|
|
1
|
+
{"version":3,"sources":["../../src/utils/ipfs.ts"],"sourcesContent":["const DEFAULT_GATEWAY = \"/api/ipfs/\";\n\nconst ALLOWED_PROTOCOLS = new Set([\"http:\", \"https:\", \"ipfs:\"]);\n\nexport function ipfsToHttp(\n uri: string | null | undefined,\n gateway = DEFAULT_GATEWAY\n): string {\n if (!uri) return \"\";\n if (uri.startsWith(\"ipfs://\")) {\n return uri.replace(\"ipfs://\", gateway);\n }\n if (uri.startsWith(\"data:image/\")) {\n return uri;\n }\n try {\n const { protocol } = new URL(uri);\n if (!ALLOWED_PROTOCOLS.has(protocol)) return \"\";\n } catch {\n return \"\";\n }\n return uri;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,kBAAkB;AAExB,MAAM,oBAAoB,oBAAI,IAAI,CAAC,SAAS,UAAU,OAAO,CAAC;AAEvD,SAAS,WACd,KACA,UAAU,iBACF;AACR,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI,IAAI,WAAW,SAAS,GAAG;AAC7B,WAAO,IAAI,QAAQ,WAAW,OAAO;AAAA,EACvC;AACA,MAAI,IAAI,WAAW,aAAa,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI;AACF,UAAM,EAAE,SAAS,IAAI,IAAI,IAAI,GAAG;AAChC,QAAI,CAAC,kBAAkB,IAAI,QAAQ,EAAG,QAAO;AAAA,EAC/C,QAAQ;AACN,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":[]}
|
package/dist/utils/ipfs.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
const DEFAULT_GATEWAY = `${MEDIA_BASE_URL}/media/ipfs/`;
|
|
1
|
+
const DEFAULT_GATEWAY = "/api/ipfs/";
|
|
3
2
|
const ALLOWED_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "ipfs:"]);
|
|
4
3
|
function ipfsToHttp(uri, gateway = DEFAULT_GATEWAY) {
|
|
5
4
|
if (!uri) return "";
|
|
6
5
|
if (uri.startsWith("ipfs://")) {
|
|
7
6
|
return uri.replace("ipfs://", gateway);
|
|
8
7
|
}
|
|
9
|
-
if (uri.startsWith(
|
|
8
|
+
if (uri.startsWith("data:image/")) {
|
|
10
9
|
return uri;
|
|
11
10
|
}
|
|
12
11
|
try {
|
|
@@ -15,9 +14,6 @@ function ipfsToHttp(uri, gateway = DEFAULT_GATEWAY) {
|
|
|
15
14
|
} catch {
|
|
16
15
|
return "";
|
|
17
16
|
}
|
|
18
|
-
if (uri.startsWith("https://") || uri.startsWith("http://")) {
|
|
19
|
-
return `${MEDIA_BASE_URL}/media/external?url=${encodeURIComponent(uri)}`;
|
|
20
|
-
}
|
|
21
17
|
return uri;
|
|
22
18
|
}
|
|
23
19
|
export {
|
package/dist/utils/ipfs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/ipfs.ts"],"sourcesContent":["const
|
|
1
|
+
{"version":3,"sources":["../../src/utils/ipfs.ts"],"sourcesContent":["const DEFAULT_GATEWAY = \"/api/ipfs/\";\n\nconst ALLOWED_PROTOCOLS = new Set([\"http:\", \"https:\", \"ipfs:\"]);\n\nexport function ipfsToHttp(\n uri: string | null | undefined,\n gateway = DEFAULT_GATEWAY\n): string {\n if (!uri) return \"\";\n if (uri.startsWith(\"ipfs://\")) {\n return uri.replace(\"ipfs://\", gateway);\n }\n if (uri.startsWith(\"data:image/\")) {\n return uri;\n }\n try {\n const { protocol } = new URL(uri);\n if (!ALLOWED_PROTOCOLS.has(protocol)) return \"\";\n } catch {\n return \"\";\n }\n return uri;\n}\n"],"mappings":"AAAA,MAAM,kBAAkB;AAExB,MAAM,oBAAoB,oBAAI,IAAI,CAAC,SAAS,UAAU,OAAO,CAAC;AAEvD,SAAS,WACd,KACA,UAAU,iBACF;AACR,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI,IAAI,WAAW,SAAS,GAAG;AAC7B,WAAO,IAAI,QAAQ,WAAW,OAAO;AAAA,EACvC;AACA,MAAI,IAAI,WAAW,aAAa,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI;AACF,UAAM,EAAE,SAAS,IAAI,IAAI,IAAI,GAAG;AAChC,QAAI,CAAC,kBAAkB,IAAI,QAAQ,EAAG,QAAO;AAAA,EAC/C,QAAQ;AACN,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":[]}
|