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

@@ -23,6 +23,7 @@
*/
import queryString from "query-string";
import { RouteComponentProps } from "react-router-dom";
//@ts-ignore
export const contextPath = window.ctxPath || "";
@@ -87,3 +88,12 @@ export function stripEndingSlash(url: string) {
}
return url;
}
export function matchedUrlFromMatch(match: any) {
return stripEndingSlash(match.url);
}
export function matchedUrl(props: RouteComponentProps) {
const match = props.match;
return matchedUrlFromMatch(match);
}