Skip to content

Commit

Permalink
added regex logic for groups and events in pageBreadcrumbs.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
shgxshg committed Dec 11, 2024
1 parent 15d2b2a commit 64bf427
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions frontend/components/page/PageBreadcrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,33 @@ let group: Group;
let event: Event;
const organizationRegex =
/^(http:\/\/localhost:\d+|https?:\/\/[\w.-]+)(\/[a-z]{2})?\/organizations\/[0-9a-fA-F-]+(\/about)?$/;
const groupRegex =
/^(http:\/\/localhost:\d+|https?:\/\/[\w.-]+)(\/[a-z]{2})?\/organizations\/[0-9a-fA-F-]+\/groups\/([0-9a-fA-F-]+)(\/about)?$/;
const eventRegex =
/^(http:\/\/localhost:\d+|https?:\/\/[\w.-]+)(\/[a-z]{2})?\/events\/([0-9a-fA-F-]+)(\/about)?$/;
if (organizationRegex.test(url)) {
pageType = "organization";
await organizationStore.fetchById(id);
organization = organizationStore.organization;
} else if (url.includes("/organizations/") && url.includes("/groups/")) {
} else if (groupRegex.test(url)) {
pageType = "group";
await groupStore.fetchById(idGroup);
group = groupStore.group;
} else if (
url.includes("/events/") &&
!url.includes("/organizations/") &&
!url.includes("/groups/") &&
!url.includes("/events/create") &&
!url.includes("/events/search")
) {
const match = url.match(groupRegex);
const groupId = match ? match[4] : null;
if (groupId) {
await groupStore.fetchById(groupId);
group = groupStore.group;
}
} else if (eventRegex.test(url)) {
pageType = "event";
await eventStore.fetchById(id);
event = eventStore.event;
const match = url.match(eventRegex);
const eventId = match ? match[3] : null;
if (eventId) {
await eventStore.fetchById(eventId);
event = eventStore.event;
}
}
const breadcrumbs = ref<string[]>([]);
Expand Down

0 comments on commit 64bf427

Please sign in to comment.