From af1e18606966bfbdbb9904419e0493b2676021a1 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Wed, 17 Feb 2021 19:43:10 +0100 Subject: [PATCH] fix: do not error when generating slug if not track title is present --- src/models/Track.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/Track.js b/src/models/Track.js index 738c5ee..fa89ff7 100644 --- a/src/models/Track.js +++ b/src/models/Track.js @@ -59,7 +59,7 @@ schema.pre('validate', async function (next) { class Track extends mongoose.Model { slugify() { - this.slug = slug(this.title) + '-' + ((Math.random() * Math.pow(36, 6)) | 0).toString(36); + this.slug = slug(this.title || 'track') + '-' + ((Math.random() * Math.pow(36, 6)) | 0).toString(36); } async generateOriginalFilePath() {