Extract common function 'matchedUrl'

This commit is contained in:
René Pfeuffer
2020-09-18 17:38:10 +02:00
parent 4523e22feb
commit bbfe2b08bc
11 changed files with 43 additions and 79 deletions

View File

@@ -55,20 +55,17 @@ type Props = RouteComponentProps &
};
class Admin extends React.Component<Props> {
matchedUrl = () => {
return urls.stripEndingSlash(this.props.match.url);
};
matchesRoles = (route: any) => {
const url = this.matchedUrl();
const url = urls.matchedUrl(this.props);
const regex = new RegExp(`${url}/role/`);
return route.location.pathname.match(regex);
};
render() {
const { links, availablePluginsLink, installedPluginsLink, t } = this.props;
const { links, availablePluginsLink, installedPluginsLink, match, t } = this.props;
const url = this.matchedUrl();
const url = urls.matchedUrl(this.props);
const extensionProps = {
links,
url