Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert removal of redirect in Dev UI Deep links #39896

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,47 @@ export class RouterController {

RouterController.router.addRoutes(routes);

if(currentSelection === path){
var currentSelection = window.location.pathname;
const search = this.getQueryParamsWithoutFrom();

var relocationRequest = this.getQueryParameter("from");
if (relocationRequest) {
// We know and already loaded the requested location
if (relocationRequest === path) {
Router.go({pathname: path, search});
}
} else if(currentSelection === path){
Router.go({pathname: path, search});
}else if(!RouterController.router.location.route && currentSelection.endsWith('/dev-ui/') && defaultRoute) {
} else if(!RouterController.router.location.route && currentSelection.endsWith('/dev-ui/') && defaultRoute) {
Router.go({pathname: path, search});
// We do not know and have not yet loaded the requested location
} else if (!RouterController.router.location.route && defaultRoute) {
// pass original query param
const currentQueryString = window.location.search;
const origSearch = currentQueryString?.length > 0 ? '&' + currentQueryString : '';

Router.go({
pathname: path,
search: '?from=' + currentSelection + origSearch,
});
}
}
}

getQueryParamsWithoutFrom() {
const params = new URLSearchParams(window.location.search);
if (params) {
const paramsWithoutFrom = [];
params.forEach((value, key) => {
if (key !== 'from') {
paramsWithoutFrom.push(key + '=' + value)
}
});
if (paramsWithoutFrom.length > 0) {
return paramsWithoutFrom.join('&');
}
}
return '';
}

getQueryParameters() {
Expand Down