smaller uniq id in custom_url

This commit is contained in:
Tykayn 2021-05-03 14:57:28 +02:00 committed by tykayn
parent f1e5903d0a
commit 5d39b7aa3e
2 changed files with 7 additions and 1 deletions

View File

@ -142,6 +142,7 @@ export class PollService implements Resolve<Poll> {
}
public convertTextToSlug(str: string) {
str = str.trim();
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();

View File

@ -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),
});
}
}