Skip to content

Commit

Permalink
Merge pull request nextcloud#5196 from nextcloud/backport/5170/stable3.5
Browse files Browse the repository at this point in the history
[stable3.5] Fix issue with Attendee not being string crashing tooltip
  • Loading branch information
st3iny authored Sep 5, 2023
2 parents 7cee446 + 8350106 commit af21e82
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/utils/attendee.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
* @return {string} URI without a mailto prefix
*/
export function removeMailtoPrefix(uri) {
if (typeof uri !== 'string') {
return ''
}

if (uri.startsWith('mailto:')) {
return uri.substr(7)
}
Expand All @@ -41,6 +45,10 @@ export function removeMailtoPrefix(uri) {
* @return {string} URI with a mailto prefix
*/
export function addMailtoPrefix(uri) {
if (typeof uri !== 'string') {
return 'mailto:'
}

if (uri.startsWith('mailto:')) {
return uri
}
Expand Down
10 changes: 10 additions & 0 deletions tests/javascript/unit/utils/attendee.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,22 @@ describe('utils/attendee test suite', () => {
expect(removeMailtoPrefix(`mailto:${uri}`)).toEqual(uri)
})

it('should return blank strings when uris are not of type string', () => {
expect(removeMailtoPrefix(null)).toEqual('')
expect(removeMailtoPrefix(undefined)).toEqual('')
})

it('should add mailto prefixes to uris', () => {
const uri = '[email protected]'
const uriWithPrefix = `mailto:${uri}`
expect(addMailtoPrefix(uri)).toEqual(uriWithPrefix)
expect(addMailtoPrefix(uriWithPrefix)).toEqual(uriWithPrefix)
})

it('should add mailto prefixes to uris when they are not of type string', () => {
expect(addMailtoPrefix(null)).toEqual("mailto:")
expect(addMailtoPrefix(undefined)).toEqual("mailto:")
})

it('should extract a display name of an organizer', () => {
const commonName = 'My Name'
Expand Down

0 comments on commit af21e82

Please sign in to comment.