From 5d39b7aa3e5f045f4270729f6c6daa2cd9ea79a9 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 3 May 2021 14:57:28 +0200 Subject: [PATCH] smaller uniq id in custom_url --- src/app/core/services/poll.service.ts | 1 + .../form/base-config/base-config.component.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 24bf1817..a3a9b9b5 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -142,6 +142,7 @@ export class PollService implements Resolve { } public convertTextToSlug(str: string) { + str = str.trim(); str = str.replace(/^\s+|\s+$/g, ''); // trim str = str.toLowerCase(); diff --git a/src/app/features/administration/form/base-config/base-config.component.ts b/src/app/features/administration/form/base-config/base-config.component.ts index 904ce3e3..24a4063f 100644 --- a/src/app/features/administration/form/base-config/base-config.component.ts +++ b/src/app/features/administration/form/base-config/base-config.component.ts @@ -46,6 +46,11 @@ export class BaseConfigComponent { * set the poll custom_url from other data of the poll */ automaticSlug(): void { - this.form.patchValue({ custom_url: this.utilitiesService.makeUuid() }); + this.form.patchValue({ + custom_url: + this.pollService.convertTextToSlug(this.form.value.title) + + '_' + + this.utilitiesService.makeUuid().substr(0, 12), + }); } }