-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
PhotoNomad0
committed
Dec 13, 2023
1 parent
e512338
commit eb9e40c
Showing
8 changed files
with
61 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,30 @@ | ||
/** | ||
* parse the new page path | ||
* @param {string} path - in format such as `/` , `/settings` or `/?server=QA` | ||
* @returns {{page: string, params: object}} | ||
* @returns {{pageId: string, params: object}} | ||
*/ | ||
export function parsePage(path) { | ||
if ((typeof path === 'string') && (path[0] === '/')) { | ||
const parts = path.substr(1).split('?') // remove any parameters | ||
const page = parts[0] | ||
const pageId = parts[0] | ||
return { | ||
page, | ||
pageId, | ||
params: parts?.length > 1 ? parts[1] : '', | ||
} | ||
} | ||
return {} | ||
} | ||
|
||
/** | ||
* reload the app at specific page and with specific params | ||
* @param {string} page - to go to (e.g. `/`) | ||
* @param {string} params - to add after ? (e.g. `server=QA`) | ||
*/ | ||
export function reloadPage(page, params) { | ||
let url = `${window.location.host}${page || '/'}` | ||
|
||
if (params) { // if there are parameters to add | ||
url = url + `?${params}` | ||
} | ||
window.location.assign(url) // reload page | ||
} |