@capillarytech/creatives-library 7.13.8 → 7.13.10
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/package.json
CHANGED
|
@@ -27,7 +27,7 @@ const CREATIVES_CDN_QUALITY_CONFIG_KEY = 'CREATIVES_CDN_QUALITY_CONFIG';
|
|
|
27
27
|
const CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX_KEY = 'CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX';
|
|
28
28
|
|
|
29
29
|
const HTTPS_STR = "https://"
|
|
30
|
-
const ALLOWED_EXTENSIONS_STR = ".*(?:jpg|png|jpeg)$"
|
|
30
|
+
const ALLOWED_EXTENSIONS_STR = ".*(?:jpg|png|jpeg|gif)$"
|
|
31
31
|
const ANY_STR = ".*"
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -260,6 +260,9 @@ export const getCdnUrl = ({
|
|
|
260
260
|
* @returns htmlContents with updated urls in image tag
|
|
261
261
|
*/
|
|
262
262
|
export const updateImagesInHtml = (htmlContents) => {
|
|
263
|
+
if(!htmlContents || typeof htmlContents !== "string"){
|
|
264
|
+
return htmlContents;
|
|
265
|
+
}
|
|
263
266
|
const copiedHtmlContents = htmlContents;
|
|
264
267
|
try {
|
|
265
268
|
const root = parse(htmlContents);
|
|
@@ -113,7 +113,19 @@ describe("cdnTransformationTests", () => {
|
|
|
113
113
|
expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
it("Should replace s3 url with cdn url for email
|
|
116
|
+
it("Should replace s3 url with cdn url for email for gif formats", () => {
|
|
117
|
+
const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/02557e68-6b7b-4d0e-ba6f-efcf8972.gif`;
|
|
118
|
+
const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
|
|
119
|
+
url: TEST_S3_URL,
|
|
120
|
+
channelName: "EMAIL",
|
|
121
|
+
height: 100,
|
|
122
|
+
width: 200,
|
|
123
|
+
});
|
|
124
|
+
const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=200,height=100,format=auto,quality=75,/intouch_creative_assets/02557e68-6b7b-4d0e-ba6f-efcf8972.gif`;
|
|
125
|
+
expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("Should replace s3 url with cdn url for email without transformation for formats other than jpg/png/jpeg/gif", () => {
|
|
117
129
|
const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.avif`; //this is random url
|
|
118
130
|
const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
|
|
119
131
|
url: TEST_S3_URL,
|
|
@@ -194,6 +206,12 @@ describe("cdnTransformationTests", () => {
|
|
|
194
206
|
const expected = mockdata.emailRawTransformed;
|
|
195
207
|
expect(htmlContentsOutput).toEqual(expected);
|
|
196
208
|
});
|
|
209
|
+
|
|
210
|
+
it("should return input itself if input is either among undefined/null/empty string", () => {
|
|
211
|
+
expect(cdnUtils.updateImagesInHtml(undefined)).toEqual(undefined);
|
|
212
|
+
expect(cdnUtils.updateImagesInHtml(null)).toEqual(null);
|
|
213
|
+
expect(cdnUtils.updateImagesInHtml("")).toEqual("");
|
|
214
|
+
});
|
|
197
215
|
});
|
|
198
216
|
|
|
199
217
|
describe("transformEmailTemplate()", () => {
|