mirror of https://github.com/nextcloud/calendar
Fix issue with Attendee not being string crashing tooltip
Signed-off-by: Mason Brothers <brothers.mason@gmail.com>
This commit is contained in:
parent
3977b5e305
commit
ac300db723
|
@ -27,6 +27,8 @@
|
|||
* @return {string} URI without a mailto prefix
|
||||
*/
|
||||
export function removeMailtoPrefix(uri) {
|
||||
if (typeof uri !== 'string') return ''
|
||||
|
||||
if (uri.startsWith('mailto:')) {
|
||||
return uri.slice(7)
|
||||
}
|
||||
|
@ -41,6 +43,8 @@ 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
|
||||
}
|
||||
|
|
|
@ -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 = 'principal@test.com'
|
||||
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'
|
||||
|
|
Loading…
Reference in New Issue