Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added regex logic for groups and events in PageBreadcrumbs.vue #1062

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions frontend/components/page/PageBreadcrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
const paramsIdGroup = useRoute().params.groupId;

const id = typeof paramsId === "string" ? paramsId : undefined;
const idGroup = typeof paramsIdGroup === "string" ? paramsIdGroup : undefined;

Check failure on line 90 in frontend/components/page/PageBreadcrumbs.vue

View workflow job for this annotation

GitHub Actions / Run PR Frontend Check

'idGroup' is assigned a value but never used. Allowed unused vars must match /^_/u

const organizationStore = useOrganizationStore();
const groupStore = useGroupStore();
Expand All @@ -98,25 +98,33 @@
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
Loading