aboutsummaryrefslogtreecommitdiff
path: root/utils/imageUtils.js
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-10-28 22:50:51 +0700
committerFactiven <[email protected]>2023-10-28 22:50:51 +0700
commita25282429761ff0670a50fd74f8c24bdb38e728c (patch)
tree0cd14840e665f1912842967de7427a31556190e6 /utils/imageUtils.js
parentUpdate v4.2.3 (diff)
downloadmoopa-a25282429761ff0670a50fd74f8c24bdb38e728c.tar.xz
moopa-a25282429761ff0670a50fd74f8c24bdb38e728c.zip
Update v4.2.4
Diffstat (limited to 'utils/imageUtils.js')
-rw-r--r--utils/imageUtils.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/utils/imageUtils.js b/utils/imageUtils.js
index e5ac6a9..56c98fb 100644
--- a/utils/imageUtils.js
+++ b/utils/imageUtils.js
@@ -20,3 +20,14 @@ export function getHeaders(providerId) {
export function getRandomId() {
return Math.random().toString(36).substr(2, 9);
}
+
+export function truncateImgUrl(url) {
+ // Find the index of .png if not found find the index of .jpg
+ let index =
+ url.indexOf(".png") !== -1 ? url.indexOf(".png") : url.indexOf(".jpg");
+ if (index !== -1) {
+ // If .png is found
+ url = url.slice(0, index + 4); // Slice the string from the start to the index of .png plus 4 (the length of .png)
+ }
+ return url;
+}