mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
100414: Add entities to allowed object route
This commit is contained in:
@@ -42,6 +42,13 @@ export class SearchTrackerComponent extends SearchComponent implements OnInit, O
|
|||||||
*/
|
*/
|
||||||
uuidRegex = /\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/g;
|
uuidRegex = /\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/g;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of paths that are considered to be the start of a route to an object page (excluding "/", e.g. "items")
|
||||||
|
* These are expected to end on an object UUID
|
||||||
|
* If they match the route we're navigating to, an object property will be added to the search event sent
|
||||||
|
*/
|
||||||
|
allowedObjectPaths: string[] = ['entities', ITEM_MODULE_PATH, COLLECTION_MODULE_PATH, COMMUNITY_MODULE_PATH];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array to track all subscriptions and unsubscribe them onDestroy
|
* Array to track all subscriptions and unsubscribe them onDestroy
|
||||||
* @type {Array}
|
* @type {Array}
|
||||||
@@ -142,12 +149,12 @@ export class SearchTrackerComponent extends SearchComponent implements OnInit, O
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the UUID from a DSO url
|
* Get the UUID from a DSO url
|
||||||
* Return null if the url isn't a community, collection or item page or the UUID couldn't be found
|
* Return null if the url isn't an object page (allowedObjectPaths) or the UUID couldn't be found
|
||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
getDsoUUIDFromUrl(url: string): string {
|
getDsoUUIDFromUrl(url: string): string {
|
||||||
if (isNotEmpty(url)) {
|
if (isNotEmpty(url)) {
|
||||||
if (url.startsWith(`/${ITEM_MODULE_PATH}`) || url.startsWith(`/${COLLECTION_MODULE_PATH}`) || url.startsWith(`/${COMMUNITY_MODULE_PATH}`)) {
|
if (this.allowedObjectPaths.some((path) => url.startsWith(`/${path}`))) {
|
||||||
const uuid = url.substring(url.lastIndexOf('/') + 1);
|
const uuid = url.substring(url.lastIndexOf('/') + 1);
|
||||||
if (uuid.match(this.uuidRegex)) {
|
if (uuid.match(this.uuidRegex)) {
|
||||||
return uuid;
|
return uuid;
|
||||||
|
Reference in New Issue
Block a user