@managesome/eposmatic-toolkit 0.2.516 → 0.2.517
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.
|
@@ -53,6 +53,12 @@ function getImageVariantUrl(downloadUrl, size) {
|
|
|
53
53
|
const result = new URL(`https://${VARIANTS_HOST}/v0/b/${variantsBucket}/o/`);
|
|
54
54
|
result.pathname += encodeURIComponent(variantPath);
|
|
55
55
|
result.searchParams.set('alt', 'media');
|
|
56
|
+
// Preserve a cache-busting timestamp from the original URL (if present) so
|
|
57
|
+
// variant URLs refresh in sync with the source image.
|
|
58
|
+
const originalTimestamp = url.searchParams.get('timestamp');
|
|
59
|
+
if (originalTimestamp !== null) {
|
|
60
|
+
result.searchParams.set('timestamp', originalTimestamp);
|
|
61
|
+
}
|
|
56
62
|
return result.toString();
|
|
57
63
|
}
|
|
58
64
|
/**
|
|
@@ -29,6 +29,11 @@ describe('getImageVariantUrl', () => {
|
|
|
29
29
|
expect((0, image_url_helpers_1.getImageVariantUrl)(input, '256x256')).toContain('logo_256x256.webp');
|
|
30
30
|
expect((0, image_url_helpers_1.getImageVariantUrl)(input, '512x512')).toContain('logo_512x512.webp');
|
|
31
31
|
});
|
|
32
|
+
it('preserves the timestamp query from the original URL', () => {
|
|
33
|
+
const input = 'https://firebasestorage.googleapis.com/v0/b/prod-managesome.appspot.com/o/images%2Fcommon%2Flogo.png?alt=media&token=abc×tamp=1710000000000';
|
|
34
|
+
const expected = 'https://firebasestorage.googleapis.com/v0/b/prod-managesome-variants/o/images%2Fcommon%2Flogo_128x128.webp?alt=media×tamp=1710000000000';
|
|
35
|
+
expect((0, image_url_helpers_1.getImageVariantUrl)(input, '128x128')).toBe(expected);
|
|
36
|
+
});
|
|
32
37
|
it('treats a leading-dot filename as extensionless', () => {
|
|
33
38
|
const input = 'https://firebasestorage.googleapis.com/v0/b/prod-managesome.appspot.com/o/images%2Fcommon%2F.webp?alt=media&token=abc';
|
|
34
39
|
const expected = 'https://firebasestorage.googleapis.com/v0/b/prod-managesome-variants/o/images%2Fcommon%2F.webp_128x128?alt=media';
|