From 1228848d4f9d921aecfd0688e20c237618b0d160 Mon Sep 17 00:00:00 2001
From: tekay <tom.kaesler@mni.thm.de>
Date: Fri, 27 Nov 2020 08:57:29 +0100
Subject: [PATCH] Fix parsing shortId

It is also possible to have letters as shortId.
---
 src/app/components/shared/header/header.component.ts | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/app/components/shared/header/header.component.ts b/src/app/components/shared/header/header.component.ts
index 65a86fe58..b765ae305 100644
--- a/src/app/components/shared/header/header.component.ts
+++ b/src/app/components/shared/header/header.component.ts
@@ -96,14 +96,10 @@ export class HeaderComponent implements OnInit {
       if (val instanceof NavigationEnd) {
         /* segments gets all parts of the url */
         const segments = this.router.parseUrl(this.router.url).root.children.primary.segments;
-        const shortIdRegExp = new RegExp('^[0-9]{8}$');
-        segments.forEach(element => {
-          /* searches the url segments for a short id */
-          if (shortIdRegExp.test(element.path)) {
-            this.shortId = element.path;
-            localStorage.setItem('shortId', this.shortId);
-          }
-        });
+        if (segments && segments.length > 2) {
+          this.shortId = segments[2].toString();
+          localStorage.setItem('shortId', this.shortId);
+        }
       }
     });
     this.moderationEnabled = (localStorage.getItem('moderationEnabled') === 'true') ? true : false;
-- 
GitLab