@jay-framework/wix-utils 0.20.0 → 0.22.0
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/index.d.ts +7 -1
- package/dist/index.js +6 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
* - wix:document://v1/<id>/<name>
|
|
10
10
|
* - wix:audio://v1/<id>/<name>
|
|
11
11
|
*/
|
|
12
|
+
/**
|
|
13
|
+
* Strip /v1/... resize parameters from a Wix static media URL.
|
|
14
|
+
* REST APIs return URLs like https://static.wixstatic.com/media/<id>/v1/fit/w_2316,h_3474,q_90/file.jpg
|
|
15
|
+
* but templates need the bare URL so they can append their own resize params.
|
|
16
|
+
*/
|
|
17
|
+
declare function stripWixMediaResize(url: string): string;
|
|
12
18
|
type WixMediaType = 'image' | 'video' | 'document' | 'audio' | 'unknown';
|
|
13
19
|
/**
|
|
14
20
|
* Parsed Wix media URL with extracted metadata
|
|
@@ -68,4 +74,4 @@ declare function getDocumentUrl(url: string): string;
|
|
|
68
74
|
*/
|
|
69
75
|
declare function getAudioUrl(url: string): string;
|
|
70
76
|
|
|
71
|
-
export { type ParsedWixMediaUrl, type WixMediaType, formatWixMediaUrl, getAudioUrl, getDocumentUrl, getVideoPosterUrl, parseWixImageUrl, parseWixMediaUrl, parseWixVideoUrl };
|
|
77
|
+
export { type ParsedWixMediaUrl, type WixMediaType, formatWixMediaUrl, getAudioUrl, getDocumentUrl, getVideoPosterUrl, parseWixImageUrl, parseWixMediaUrl, parseWixVideoUrl, stripWixMediaResize };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
function stripWixMediaResize(url) {
|
|
2
|
+
return url.replace(/\/v1\/(?:fit|fill|crop)\/[^/]+\/file\.\w+$/, "");
|
|
3
|
+
}
|
|
1
4
|
function parseWixMediaUrl(url) {
|
|
2
5
|
if (!url) return null;
|
|
3
6
|
const match = url.match(
|
|
@@ -42,7 +45,7 @@ function formatWixMediaUrl(_id, url, resize) {
|
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
if ((url == null ? void 0 : url.startsWith("http://")) || (url == null ? void 0 : url.startsWith("https://"))) {
|
|
45
|
-
return url;
|
|
48
|
+
return stripWixMediaResize(url) + resizeFragment;
|
|
46
49
|
}
|
|
47
50
|
if (_id) {
|
|
48
51
|
return `https://static.wixstatic.com/media/${_id}${resizeFragment}`;
|
|
@@ -75,5 +78,6 @@ export {
|
|
|
75
78
|
getVideoPosterUrl,
|
|
76
79
|
parseWixImageUrl,
|
|
77
80
|
parseWixMediaUrl,
|
|
78
|
-
parseWixVideoUrl
|
|
81
|
+
parseWixVideoUrl,
|
|
82
|
+
stripWixMediaResize
|
|
79
83
|
};
|