MCPcopy Index your code
hub / github.com/parse-community/parse-dashboard / generatePath

Function generatePath

src/lib/generatePath.js:3–34  ·  view source on GitHub ↗
(currentApp, path, prependMountPath = false)

Source from the content-addressed store, hash-verified

1const MOUNT_PATH = window.PARSE_DASHBOARD_PATH;
2
3export default function generatePath(currentApp, path, prependMountPath = false) {
4
5 const urlObj = new URL(path, window.location.origin);
6 const params = new URLSearchParams(urlObj.search);
7
8 const filters = JSON.parse(params.get('filters'))
9
10 if (filters) {
11 for (let i = 0; i < filters.length; i++) {
12 const filter = filters[i];
13 if (filter.compareTo?.__type === 'RelativeDate') {
14 const date = new Date();
15 date.setTime(date.getTime() + filter.compareTo.value * 1000);
16 filter.compareTo = {
17 __type: 'Date',
18 iso: date.toISOString(),
19 }
20 filters[i] = filter;
21 }
22 }
23
24 params.set('filters', JSON.stringify(filters));
25 urlObj.search = params.toString();
26
27 path = urlObj.toString().split(window.location.origin)[1].substring(1);
28 }
29
30 if (prependMountPath && MOUNT_PATH) {
31 return `${MOUNT_PATH}apps/${currentApp.slug}/${path}`;
32 }
33 return `/apps/${currentApp.slug}/${path}`;
34}

Callers 15

urlForKeyFunction · 0.85
handleSendPushMethod · 0.85
handlePushSubmitFunction · 0.85
navigateToNewFunction · 0.85
navigateToDetailsFunction · 0.85
updateURLFunction · 0.85
redirectToFirstClassFunction · 0.85
createClassFunction · 0.85
dropClassFunction · 0.85
updateFiltersFunction · 0.85

Calls 2

getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected