Skip to content

Commit

Permalink
remove webUrl from required props
Browse files Browse the repository at this point in the history
  • Loading branch information
lauribohm committed Jan 25, 2024
1 parent b93caa6 commit 71d62d0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions search-parts/src/components/SpoPathBreadcrumbComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class SpoPathBreadcrumb extends React.Component<IBreadcrumbProps, IBreadc
},
};

const breadcrumbItems = this.validateEntityProps(path, siteUrl, webUrl, entityTitle) ? this.getBreadcrumbItems(path, siteUrl, webUrl, entityTitle, entityFileType, includeSiteName, includeEntityName, breadcrumbItemsAsLinks) : undefined;
const breadcrumbItems = this.validateEntityProps(path, siteUrl, entityTitle) ? this.getBreadcrumbItems(path, siteUrl, webUrl, entityTitle, entityFileType, includeSiteName, includeEntityName, breadcrumbItemsAsLinks) : undefined;

return (
<>
Expand All @@ -125,10 +125,9 @@ export class SpoPathBreadcrumb extends React.Component<IBreadcrumbProps, IBreadc
)
}

private validateEntityProps = (path: string, siteUrl: string, webUrl: string, entityTitle: string): boolean => {
private validateEntityProps = (path: string, siteUrl: string, entityTitle: string): boolean => {
return path !== undefined && path !== null
&& siteUrl !== undefined && siteUrl !== null
&& webUrl !== undefined && webUrl !== null
&& entityTitle !== undefined && entityTitle !== null;
}

Expand All @@ -137,6 +136,9 @@ export class SpoPathBreadcrumb extends React.Component<IBreadcrumbProps, IBreadc
// webUrl: https://contoso.sharepoint.com/sites/sitename/subsite
// path: https://contoso.sharepoint.com/sites/sitename/subsite/Shared Documents/Document.docx

// All entities don't have a webUrl property (e.g. list and doc libs). Therefore webUrl is not part of props validation and undefined/null check is needed here.
if (webUrl === undefined || webUrl === null) webUrl = siteUrl;

const frags = webUrl.split('/');
// frags: ["https:", "", "contoso.sharepoint.com", "sites", "sitename", "subsite"]

Expand Down Expand Up @@ -191,7 +193,7 @@ export class SpoPathBreadcrumb extends React.Component<IBreadcrumbProps, IBreadc

breadcrumbItems.unshift(item);
}

return breadcrumbItems;
}
}
Expand Down

0 comments on commit 71d62d0

Please sign in to comment.