diff options
| author | Factiven <[email protected]> | 2023-11-18 10:04:17 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-18 10:04:17 +0700 |
| commit | d8630f8011dab6c81aee0abbd74d88b2e0176d33 (patch) | |
| tree | b72a73ff1695df43464a02249b10f8fe7a443277 /utils/imageUtils.js | |
| parent | Update [id].js (diff) | |
| download | moopa-pre-v4.3.0.tar.xz moopa-pre-v4.3.0.zip | |
Update pre-v4.3.0 - Merged Branch pre-push-prev4.3.0 to main (#98)pre-v4.3.0
* Update pre-v4.3.0
* Update aniAdvanceSearch.js
Diffstat (limited to 'utils/imageUtils.js')
| -rw-r--r-- | utils/imageUtils.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/utils/imageUtils.js b/utils/imageUtils.js index 56c98fb..8025d5b 100644 --- a/utils/imageUtils.js +++ b/utils/imageUtils.js @@ -24,10 +24,15 @@ export function getRandomId() { 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"); + 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) + // If .png or .jpg is found + url = url?.slice(0, index + 4); // Slice the string from the start to the index of .png or .jpg plus 4 (the length of .png or .jpg) + } else { + // If .png or .jpg is not found + return url; // Return the original url string } + return url; } |