Skip to content

Commit

Permalink
Merge pull request #33238 from rojiphil/33215-app-unusable-older-safari
Browse files Browse the repository at this point in the history
fix older safari launch app issue
  • Loading branch information
Julesssss authored Dec 21, 2023
2 parents b966bd4 + 7043a17 commit 8970aa3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libs/UserUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ function getDefaultAvatar(accountID = -1, avatarURL?: string): React.FC<SvgProps
// But the avatar link still corresponds to the original ID-generated link. So we extract the SVG image number from the backend's link instead of using the user ID directly
let accountIDHashBucket: AvatarRange;
if (avatarURL) {
const match = avatarURL.match(/(?<=default-avatar_)\d+(?=\.)/);
const lastDigit = match && parseInt(match[0], 10);
const match = avatarURL.match(/(default-avatar_)(\d+)(?=\.)/);
const lastDigit = match && parseInt(match[2], 10);
accountIDHashBucket = lastDigit as AvatarRange;
} else {
accountIDHashBucket = ((accountID % CONST.DEFAULT_AVATAR_COUNT) + 1) as AvatarRange;
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/UserUtilsTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as UserUtils from '../../src/libs/UserUtils';

describe('UserUtils', () => {
it('should return the default avatar from the avatar url', () => {
const avatarURL = 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_7.png';
const defaultAvatar = UserUtils.getDefaultAvatar(1, avatarURL);
expect(typeof defaultAvatar).toBe('function');
});
});

0 comments on commit 8970aa3

Please sign in to comment.